PAT乙级一题不明白为什么WA

题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1478634461852217344

以下是我的C++代码,我不明白明明输出结果和答案一模一样,还测了几组样例,结果答案还是0分:


```c++
#include
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;
}

```

for (auto i : top_weigh) {
cout << i << " "[idx++ > N];
}
这样的话,每个值后面都带了一个空格,正确答案可能是最后一个值后面是没有空格的
===
[idx++ > N]这个写法还没见过,啥作用