#include <bits/stdc++.h>
using namespace std;
long long n, dd[1000005], cnt(0), a;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
fill_n(dd, 1000005, 0);
for (int i=1; i<=n; ++i)
{
cin >> a;
dd[a]++;
if (dd[a+1] > 0) dd[a+1]--;
else cnt++;
}
cout << cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9988 KB |
Output is correct |
2 |
Correct |
0 ms |
9988 KB |
Output is correct |
3 |
Correct |
0 ms |
9988 KB |
Output is correct |
4 |
Correct |
0 ms |
9988 KB |
Output is correct |
5 |
Correct |
103 ms |
9988 KB |
Output is correct |
6 |
Correct |
76 ms |
9988 KB |
Output is correct |
7 |
Correct |
59 ms |
9988 KB |
Output is correct |
8 |
Correct |
69 ms |
9988 KB |
Output is correct |
9 |
Correct |
69 ms |
9988 KB |
Output is correct |
10 |
Correct |
76 ms |
9988 KB |
Output is correct |