MAGCARI

fff

Jul 10th, 2021
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. #define endl '\n'
  5. map<int,int> mp,cnt;
  6. int32_t main(){
  7.     ios_base::sync_with_stdio(0),cin.tie(0);
  8.     int q;
  9.     cin >> q;
  10.     while(q--){
  11.         int mx=0,i,n,tmp,num;
  12.         cin >> n;
  13.         for(i=0;i<n;i++){
  14.             cin >> num;
  15.             cnt[num]++;
  16.             mx = max(mx,num);
  17.         }
  18.         for(auto x:cnt){
  19.             if(x.second>1){
  20.                 tmp = log2(x.second)+x.first;
  21.                 mx = max(mx,tmp);
  22.                 mp[tmp]=1;
  23.             }else{
  24.                 mp[x.first]=1;
  25.             }
  26.         }
  27.         cout << mx+1-mp.size() << endl;
  28.         mp.clear();
  29.         cnt.clear();
  30.     }
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment