全WA代码,在别的OJ上能AC,偏偏luogu不行,在线求调,谢!
查看原帖
全WA代码,在别的OJ上能AC,偏偏luogu不行,在线求调,谢!
1441890
Jeson_Lee楼主2024/12/1 21:43

Luogu_P1020

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        int j = 0;
        while (j < a.size() && a[j] < x) {
            ++j;
        }
        if (j == a.size()) {
            a.push_back(x);
        } else {
            a[j] = x;
        }
    }
    cout << a.size();
    return 0;
}
2024/12/1 21:43
加载中...