Advertisement
sajid161

6:4

Jan 3rd, 2021
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cin>>n;
  7.     vector<int>v(n);
  8.     for(int i=0;i<n;i++)
  9.     {
  10.         cin>>v[i];
  11.     }
  12.     map<int,int>mp;
  13.     for(auto u:v)
  14.     {
  15.         mp[u]++;
  16.     }
  17.     int coun=0;
  18.     for(auto u:mp)
  19.     {        
  20.         if(u.first<u.second)
  21.         {
  22.  
  23.             coun+=abs(u.first-u.second);
  24.         }
  25.         else if(u.first>u.second) coun+=u.second;
  26.     }
  27.    cout<<coun;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement