#include <bits/stdc++.h>
using namespace std;
#define int long long
int N, h[100005];
multiset<int> s;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N;
for (int i = 0; i < N; i++) {
cin >> h[i];
}
int c = 0;
for (int i = 0; i < N; i++) {
if (s.find(h[i] + 1) == s.end()) c++;
else s.erase(s.find(h[i] + 1));
s.insert(h[i]);
}
cout << c;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Incorrect |
13 ms |
1152 KB |
Output isn't correct |
6 |
Incorrect |
13 ms |
1152 KB |
Output isn't correct |
7 |
Incorrect |
12 ms |
1152 KB |
Output isn't correct |
8 |
Incorrect |
12 ms |
1152 KB |
Output isn't correct |
9 |
Incorrect |
13 ms |
1152 KB |
Output isn't correct |
10 |
Incorrect |
12 ms |
1152 KB |
Output isn't correct |