Advertisement
newb_ie

Untitled

Oct 15th, 2021
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. int main () {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. cout.tie(nullptr);
  8. int cnt[100000 + 10];
  9. for (int i = 1; i <= 100000; ++i) cnt[i] = 0;
  10. int n;
  11. cin >> n;
  12. int remove = 0;
  13. for (int i = 1; i <= n; ++i) {
  14. int x;
  15. cin >> x;
  16. if (x > n) {
  17. ++remove;
  18. } else {
  19. cnt[x]++;
  20. }
  21. }
  22. for (int i = 1; i <= n; ++i) {
  23. if (i > cnt[i]) {
  24. remove += cnt[i];
  25. } else {
  26. remove += cnt[i] - i;
  27. }
  28. }
  29. cout << remove << '\n';
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement