-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathD.cpp
37 lines (34 loc) · 1.09 KB
/
D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<bits/stdc++.h>
#define FORU(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b) for(int i = (a), _b = (b); i >= _b; i--)
#define FORE(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) (int)(v).size()
#define MASK(x) (1LL << (x))
#define BIT(x, i) (((x) >> (i)) & 1)
#define TASK "D"
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const int NMAX = 200005;
int N, a[NMAX], sum, cnt[NMAX], ans;
int main(void) {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout);
cin >> N;
FORU(i, 1, N) cin >> a[i];
FORU(i, 1, N) cnt[a[i]]++;
sum = 0;
FORU(i, 1, N) {
if(a[i]) {
sum += cnt[a[i]];
cnt[a[i]] = 0;
if(i > sum) ans++;
}
}
cout << ans;
return 0;
}