#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+1]) ans++;
else arr[op+1]--;
arr[op]++;
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
404 KB |
Output is correct |
3 |
Correct |
3 ms |
356 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
179 ms |
384 KB |
Output is correct |
6 |
Correct |
188 ms |
384 KB |
Output is correct |
7 |
Correct |
149 ms |
384 KB |
Output is correct |
8 |
Correct |
145 ms |
460 KB |
Output is correct |
9 |
Correct |
162 ms |
384 KB |
Output is correct |
10 |
Correct |
162 ms |
384 KB |
Output is correct |