#include <iostream>
#include <unordered_map>
using namespace std;
int i,n,ok,x,nr,d,y,j,k,v[1001];
short fr[200][30];
int sum[200];
unordered_map <int, int> m;
int main(){
cin>>n;
for(i=1;i<=n;i++){
cin>>x;
if(m[x+1]==0){
nr++;
m[x]++;
} else {
m[x+1]--;
m[x]++;
}
}
cout<<nr;
}
# |
Verdict |
Execution time |
Memory |
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 |
394 ms |
636 KB |
Output is correct |
6 |
Correct |
386 ms |
376 KB |
Output is correct |
7 |
Correct |
329 ms |
376 KB |
Output is correct |
8 |
Correct |
312 ms |
504 KB |
Output is correct |
9 |
Correct |
402 ms |
376 KB |
Output is correct |
10 |
Correct |
343 ms |
376 KB |
Output is correct |