#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int a[1000005],freq[1000005];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
int res=0;
for(int i=n-1;i>=0;i--){
freq[a[i]]++;
if(freq[a[i]-1])freq[a[i]-1]--;
else res++;
}
cout<<res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
56 ms |
6940 KB |
Output is correct |
6 |
Correct |
56 ms |
7304 KB |
Output is correct |
7 |
Correct |
52 ms |
5964 KB |
Output is correct |
8 |
Correct |
52 ms |
5848 KB |
Output is correct |
9 |
Correct |
61 ms |
6496 KB |
Output is correct |
10 |
Correct |
75 ms |
6460 KB |
Output is correct |