#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
int n,x,d[N],r;
int main()
{
cin>>n;
while(n--)
{
cin>>x;
if(!d[x]) r++,d[x-1]++;
else d[x]--,d[x-1]++;
}
cout<<r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
227 ms |
376 KB |
Output is correct |
6 |
Correct |
219 ms |
376 KB |
Output is correct |
7 |
Correct |
182 ms |
384 KB |
Output is correct |
8 |
Correct |
167 ms |
376 KB |
Output is correct |
9 |
Correct |
200 ms |
376 KB |
Output is correct |
10 |
Correct |
198 ms |
504 KB |
Output is correct |