Guest User

Untitled

a guest
Dec 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  5. #define INF 0x3f3f3f3f3f
  6.  
  7. int main() {
  8.  
  9.     fastio;
  10.  
  11.     ll test;
  12.     cin >> test;
  13.  
  14.     for(ll t = 0; t < test; t++){
  15.  
  16.         ll n , b;
  17.         string s;
  18.         ll c = 0;
  19.         map<string , pair<ll,ll> > m;
  20.  
  21.         cin >> n;
  22.         for(ll i = 0; i < n; i++){
  23.             cin >> s >> b;
  24.  
  25.             if(b == 0) m[s].first++;
  26.             else m[s].second++;
  27.         }
  28.  
  29.         for(auto x : m) c += max(x.second.first , x.second.second);
  30.  
  31.         cout << c << "\n";
  32.     }
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment