#include <iostream>
using namespace std;
int n,i,sol,v[1000010],f[1000010];
int main() {
cin>>n;
for (i=1;i<=n;i++)
cin>>v[i];
for (i=1;i<=n;i++) {
if (f[v[i]]==0) {
sol++;
f[v[i]-1]++;
}
else {
f[v[i]]--;
f[v[i]-1]++;
}
}
cout<<sol;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 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 |
332 ms |
7272 KB |
Output is correct |
6 |
Correct |
346 ms |
7320 KB |
Output is correct |
7 |
Correct |
279 ms |
6136 KB |
Output is correct |
8 |
Correct |
269 ms |
5964 KB |
Output is correct |
9 |
Correct |
303 ms |
6504 KB |
Output is correct |
10 |
Correct |
300 ms |
6776 KB |
Output is correct |