Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define int long long
- #define endl '\n'
- map<int,int> mp,cnt;
- int32_t main(){
- ios_base::sync_with_stdio(0),cin.tie(0);
- int q;
- cin >> q;
- while(q--){
- int mx=0,i,n,tmp,num;
- cin >> n;
- for(i=0;i<n;i++){
- cin >> num;
- cnt[num]++;
- mx = max(mx,num);
- }
- for(auto x:cnt){
- if(x.second>1){
- tmp = log2(x.second)+x.first;
- mx = max(mx,tmp);
- mp[tmp]=1;
- }else{
- mp[x.first]=1;
- }
- }
- cout << mx+1-mp.size() << endl;
- mp.clear();
- cnt.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment