#include <iostream>
using namespace std;
const int N=1e6;
int v[N+5];
int main()
{
int n; cin>>n;
int nr=0;
for(int i=1;i<=n;i++)
{
int x;cin>>x;
if(v[x+1]) v[x+1]--;
else nr++;
v[x]++;
}
cout<<nr;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
187 ms |
292 KB |
Output is correct |
6 |
Correct |
176 ms |
288 KB |
Output is correct |
7 |
Correct |
162 ms |
300 KB |
Output is correct |
8 |
Correct |
147 ms |
284 KB |
Output is correct |
9 |
Correct |
157 ms |
296 KB |
Output is correct |
10 |
Correct |
158 ms |
284 KB |
Output is correct |