#include <iostream>
using namespace std;
int fr[1100000], n, i, x, sol;
int main()
{
cin>>n;
for ( i=1; i <= n; i++ ){
cin>>x;
if ( !fr[x] ){
sol++;
fr[x-1]++;
} else {
fr[x]--;
fr[x-1]++;
}
}
cout<<sol;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
252 KB |
Output is correct |
3 |
Correct |
12 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
329 ms |
504 KB |
Output is correct |
6 |
Correct |
341 ms |
376 KB |
Output is correct |
7 |
Correct |
270 ms |
376 KB |
Output is correct |
8 |
Correct |
265 ms |
368 KB |
Output is correct |
9 |
Correct |
295 ms |
368 KB |
Output is correct |
10 |
Correct |
293 ms |
476 KB |
Output is correct |