#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,a[1000005],ans=0;
map<ll,ll>viz;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
}
reverse(a+1,a+n+1);
for(ll i=1;i<=n;i++)
{
if(viz[a[i]-1]==1){
viz[a[i]]=1;
continue;
}
ans++;
viz[a[i]]=1;
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
5 |
Incorrect |
206 ms |
10296 KB |
Output isn't correct |
6 |
Incorrect |
199 ms |
11104 KB |
Output isn't correct |
7 |
Incorrect |
156 ms |
8940 KB |
Output isn't correct |
8 |
Incorrect |
152 ms |
8940 KB |
Output isn't correct |
9 |
Incorrect |
182 ms |
9580 KB |
Output isn't correct |
10 |
Incorrect |
175 ms |
9984 KB |
Output isn't correct |