#include <iostream>
#include <algorithm>
using namespace std;
int n,v[1000010],f[1000010],sum,of;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>v[i];
}
for(int i=1;i<=n;i++){
if(f[v[i]]==0)
of++;
else
f[v[i]]--;
f[v[i]-1]++;
}
cout<<of;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
333 ms |
3548 KB |
Output is correct |
6 |
Correct |
356 ms |
3768 KB |
Output is correct |
7 |
Correct |
273 ms |
3160 KB |
Output is correct |
8 |
Correct |
271 ms |
3268 KB |
Output is correct |
9 |
Correct |
303 ms |
3320 KB |
Output is correct |
10 |
Correct |
301 ms |
3480 KB |
Output is correct |