#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 1e6+5;
int n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
int mx = 0;
map<int,set<int>> v;
for(int i = 0; i < n; i++) {
int x;
cin >> x;
v[-x].insert(i);
mx = max(mx, x);
}
int c = 0;
for(auto &x : v) {
if(x.second.empty()) continue;
c++;
int now = -x.first;
int pos = -1;
while(v[-now].upper_bound(pos) != v[-now].end()) {
pos = *v[-now].upper_bound(pos);
v[-now].erase(pos);
now--;
}
}
cout << c << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
640 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
5 |
Correct |
1291 ms |
37880 KB |
Output is correct |
6 |
Incorrect |
1212 ms |
42232 KB |
Output isn't correct |
7 |
Incorrect |
921 ms |
34808 KB |
Output isn't correct |
8 |
Incorrect |
913 ms |
34424 KB |
Output isn't correct |
9 |
Incorrect |
1100 ms |
36604 KB |
Output isn't correct |
10 |
Incorrect |
1033 ms |
37624 KB |
Output isn't correct |