#include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
int V[N];
for(int i = 0 ;i<N;i++)
{
cin>>V[i];
}
int H[1000002];
int conta = 0;
for(int i = 1;i<=1000001;i++)
{
H[i] = 0;
}
for(int i = 0;i<N;i++)
{
int a = V[i];
if(H[a+1]>0)
{
H[a+1] -= 1;
H[a] +=1;
}
else
{
conta++;
H[a]++;
}
}
cout<<conta;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4224 KB |
Output is correct |
2 |
Correct |
7 ms |
4224 KB |
Output is correct |
3 |
Correct |
8 ms |
4224 KB |
Output is correct |
4 |
Correct |
8 ms |
4224 KB |
Output is correct |
5 |
Correct |
274 ms |
7416 KB |
Output is correct |
6 |
Correct |
290 ms |
7800 KB |
Output is correct |
7 |
Correct |
236 ms |
7160 KB |
Output is correct |
8 |
Correct |
230 ms |
7112 KB |
Output is correct |
9 |
Correct |
253 ms |
7340 KB |
Output is correct |
10 |
Correct |
264 ms |
7288 KB |
Output is correct |