#include <bits/stdc++.h>
using namespace std;
const int mxh=1000005;
int cnt[mxh];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int res=0;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
if(cnt[x]==0)
{
res++;
}
else
{
cnt[x]--;
}
cnt[x-1]++;
}
cout<<res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
33 ms |
4052 KB |
Output is correct |
6 |
Correct |
31 ms |
3932 KB |
Output is correct |
7 |
Correct |
26 ms |
3260 KB |
Output is correct |
8 |
Correct |
27 ms |
3148 KB |
Output is correct |
9 |
Correct |
32 ms |
3524 KB |
Output is correct |
10 |
Correct |
29 ms |
3420 KB |
Output is correct |