Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- int main () {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int cnt[100000 + 10];
- for (int i = 1; i <= 100000; ++i) cnt[i] = 0;
- int n;
- cin >> n;
- int remove = 0;
- for (int i = 1; i <= n; ++i) {
- int x;
- cin >> x;
- if (x > n) {
- ++remove;
- } else {
- cnt[x]++;
- }
- }
- for (int i = 1; i <= n; ++i) {
- if (i > cnt[i]) {
- remove += cnt[i];
- } else {
- remove += cnt[i] - i;
- }
- }
- cout << remove << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement