#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define SI size()
#define pb push_back
using namespace std;
const ll MAX=1000007;
ll i,m,n,sum,a[MAX],ans;
int main(){
int ans=0;
int n;
cin>>n;
int x;
for(int i=0;i<n;i++)
{
cin>>x;
if(a[x]==0)
{
ans++;
a[x-1]++;
}
else
{
a[x]--;
a[x-1]++;
}
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
352 KB |
Output is correct |
3 |
Correct |
3 ms |
432 KB |
Output is correct |
4 |
Correct |
3 ms |
476 KB |
Output is correct |
5 |
Correct |
219 ms |
540 KB |
Output is correct |
6 |
Correct |
214 ms |
656 KB |
Output is correct |
7 |
Correct |
184 ms |
656 KB |
Output is correct |
8 |
Correct |
194 ms |
656 KB |
Output is correct |
9 |
Correct |
201 ms |
656 KB |
Output is correct |
10 |
Correct |
202 ms |
656 KB |
Output is correct |