//In The Name of Beauty
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e6 + 8;
ll const INF = 1e12 + 8;
ll const delta = 1000000007;
ll a[MAXN];
ll last[MAXN];
int main()
{
IB;
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
for(ll i = 0;i < MAXN;i++)last[i] = -1;
for(ll i = 1;i <= n;i++)cin >> a[i];
ll ans = 0;
for(ll i = n;i >= 1;i--)
{
ll t = a[i];
last[t] = i;
if(last[t - 1] == -1)ans++;
else last[t - 1] = -1;
}
cout << ans;
return 0;
}
//Written by M_H_H_7
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
8192 KB |
Output isn't correct |
2 |
Incorrect |
9 ms |
8192 KB |
Output isn't correct |
3 |
Incorrect |
10 ms |
8192 KB |
Output isn't correct |
4 |
Incorrect |
10 ms |
8192 KB |
Output isn't correct |
5 |
Incorrect |
97 ms |
14328 KB |
Output isn't correct |
6 |
Incorrect |
92 ms |
15068 KB |
Output isn't correct |
7 |
Incorrect |
89 ms |
13988 KB |
Output isn't correct |
8 |
Incorrect |
81 ms |
13812 KB |
Output isn't correct |
9 |
Incorrect |
86 ms |
14180 KB |
Output isn't correct |
10 |
Incorrect |
95 ms |
14376 KB |
Output isn't correct |