#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<int> a(n); for (int &x : a) cin >> x;
vector<int> m(1e6 + 5);
int ans = 0;
for (int i = 0; i < n; i++) {
m[a[i]]++;
if (m[a[i] + 1]) m[a[i] + 1]--;
else ans++;
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4172 KB |
Output is correct |
2 |
Correct |
2 ms |
4172 KB |
Output is correct |
3 |
Correct |
3 ms |
4172 KB |
Output is correct |
4 |
Correct |
3 ms |
4172 KB |
Output is correct |
5 |
Correct |
82 ms |
10808 KB |
Output is correct |
6 |
Correct |
98 ms |
11180 KB |
Output is correct |
7 |
Correct |
68 ms |
9916 KB |
Output is correct |
8 |
Correct |
70 ms |
9916 KB |
Output is correct |
9 |
Correct |
77 ms |
10312 KB |
Output is correct |
10 |
Correct |
77 ms |
10440 KB |
Output is correct |