#include <iostream>
using namespace std;
int n, i, sol, v[1000005], f[1000005];
int main(){
cin >> n;
for (i=1; i<=n; i++){
cin >> v[i];
}
for (i=1; i<=n; i++){
if (f[v[i]+1]){
f[v[i]+1]--;
}
else{
sol++;
}
f[v[i]]++;
}
cout << sol;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
338 ms |
6992 KB |
Output is correct |
6 |
Correct |
354 ms |
7392 KB |
Output is correct |
7 |
Correct |
271 ms |
6020 KB |
Output is correct |
8 |
Correct |
270 ms |
6048 KB |
Output is correct |
9 |
Correct |
303 ms |
6520 KB |
Output is correct |
10 |
Correct |
309 ms |
6592 KB |
Output is correct |