#include "bits/stdc++.h"
using namespace std;
int arr[(int)1e6+10];
int ans=0;
int main()
{
int n;
cin >> n;
for(int i=1;i<=n;i++)
{
int op;
cin >> op;
if(!arr[op]) ans++;
else arr[op]--;
arr[op-1]++;
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
368 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
420 KB |
Output is correct |
5 |
Correct |
186 ms |
3972 KB |
Output is correct |
6 |
Correct |
190 ms |
3948 KB |
Output is correct |
7 |
Correct |
153 ms |
3196 KB |
Output is correct |
8 |
Correct |
151 ms |
3196 KB |
Output is correct |
9 |
Correct |
172 ms |
3592 KB |
Output is correct |
10 |
Correct |
169 ms |
3456 KB |
Output is correct |