#include<bits/stdc++.h>
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define int long long int
using namespace std;
const int MOD=1e9+7;
const int INF=4000000000000000000ll;
int mul(int a,int b)
{
if(a>INF/b) return INF;
else return a*b;
}
#undef int
int main()
{
#define int long long int
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("input.txt","r",stdin);
int n;
cin>>n;
int h[n];
FOR(i,n) cin>>h[i];
int found[1000002];
fill(found,found+1000002,0);
int ans=0;
FOR(i,n)
{
if(found[h[i]]==0)
{
ans++;
}
else
{
found[h[i]]-=1;
}
found[h[i]-1]+=1;
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8184 KB |
Output is correct |
2 |
Correct |
9 ms |
8184 KB |
Output is correct |
3 |
Correct |
9 ms |
8200 KB |
Output is correct |
4 |
Correct |
14 ms |
8376 KB |
Output is correct |
5 |
Correct |
93 ms |
14416 KB |
Output is correct |
6 |
Correct |
151 ms |
15212 KB |
Output is correct |
7 |
Correct |
88 ms |
15212 KB |
Output is correct |
8 |
Correct |
88 ms |
15212 KB |
Output is correct |
9 |
Correct |
104 ms |
15212 KB |
Output is correct |
10 |
Correct |
102 ms |
15212 KB |
Output is correct |