题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1478634461852217344
以下是我的C++代码,我不明白明明输出结果和答案一模一样,还测了几组样例,结果答案还是0分:
```c++
#include<bits/stdc++.h>
using namespace std;
int N, M, max_weigh = 0, weigh;
int main() {
vector<int> top_weigh;
cin >> N >> M;
while (N--) {
for (int i = 0; i < M; i++) {
cin >> weigh;
if (weigh > max_weigh) max_weigh = weigh;
}
top_weigh.push_back(max_weigh);
max_weigh = 0;
}
int idx = 1;
for (auto i : top_weigh) {
cout << i << " "[idx++ > N];
}
cout << "\n";
cout << *max_element(top_weigh.begin(), top_weigh.end());
return 0;
}
```