Advertisement
jakaria_hossain

codechef - isolation centers

May 2nd, 2020
847
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fastread()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  4. #define ll long long
  5. int main()
  6. {
  7.     fastread()
  8.     ll t ;
  9.     cin>>t;
  10.     while (t--)
  11.     {
  12.         ll n,q;
  13.         cin>>n>>q;
  14.         string s;
  15.         cin>>s;
  16.         map<char,ll>mp;
  17.         for(ll i =0;i<n;i++)mp[s[i]]++;
  18.         while(q--)
  19.         {
  20.             ll x,cnt=0;
  21.             cin>>x;
  22.             map<char,ll>::iterator it=mp.begin();
  23.             while(it!=mp.end())
  24.             {
  25.                 if(it->second>x)cnt+=(it->second-x);
  26.                 it++;
  27.             }
  28.             cout<<cnt<<endl;
  29.             //cnt=0;
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement