#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;
map<int,set<int>> v;
for(int i = 0; i < n; i++) {
int x;
cin >> x;
v[-x].insert(i);
}
int c = 0;
for(auto &x : v) {
while(!x.second.empty()) {
c++;
int now = -x.first;
int pos = -1;
while(v[-now].upper_bound(pos) != v[-now].end()) {
int x = *v[-now].upper_bound(pos);
pos = x;
v[-now].erase(pos);
now--;
}
}
}
cout << c << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
640 KB |
Output is correct |
4 |
Correct |
4 ms |
640 KB |
Output is correct |
5 |
Correct |
1270 ms |
37796 KB |
Output is correct |
6 |
Correct |
1449 ms |
42104 KB |
Output is correct |
7 |
Correct |
1147 ms |
34840 KB |
Output is correct |
8 |
Correct |
1128 ms |
34424 KB |
Output is correct |
9 |
Correct |
1208 ms |
36344 KB |
Output is correct |
10 |
Correct |
1253 ms |
37892 KB |
Output is correct |