#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e6;
int v[nmax+5];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
int nr = 0;
for(int i=1; i<=n; i++) {
int x; cin >> x;
if(v[x+1])
v[x+1]--;
else nr++;
v[x]++;
}
cout << nr;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
57 ms |
3912 KB |
Output is correct |
6 |
Correct |
78 ms |
3768 KB |
Output is correct |
7 |
Correct |
53 ms |
3148 KB |
Output is correct |
8 |
Correct |
48 ms |
3120 KB |
Output is correct |
9 |
Correct |
54 ms |
3512 KB |
Output is correct |
10 |
Correct |
51 ms |
3404 KB |
Output is correct |