Ankit_132

A

Jun 3rd, 2024
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int t;
  6.     cin>>t;
  7.    
  8.     while(t--){
  9.         int n, m;
  10.         string s;
  11.         cin>>n>>m>>s;
  12.        
  13.         vector<int> cnt(7, m);
  14.        
  15.         for(auto e: s){
  16.             cnt[e-'A']--;
  17.             cnt[e-'A'] = max(0, cnt[e-'A']);
  18.         }
  19.        
  20.         cout<<accumulate(cnt.begin(), cnt.end(),0)<<"\n";
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment