#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 1000000;
int was[N+5];
int main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout.precision(10);
cout << fixed;
int n;
cin >> n;
int res = 0;
for(int i=1; i<=n; i++){
int x;
cin >> x;
if(was[x+1]) was[x+1]--;
else res++;
was[x]++;
}
cout << res << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
77 ms |
3900 KB |
Output is correct |
6 |
Correct |
80 ms |
3756 KB |
Output is correct |
7 |
Correct |
64 ms |
3108 KB |
Output is correct |
8 |
Correct |
61 ms |
3124 KB |
Output is correct |
9 |
Correct |
70 ms |
3508 KB |
Output is correct |
10 |
Correct |
70 ms |
3364 KB |
Output is correct |