General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
196878958 Practice:
shivanshsingh9670
1506D - 19 C++17 (GCC 7-32) Time limit exceeded on test 7 2000 ms 5828 KB 2023-03-11 06:37:40 2023-03-11 06:37:40
→ Source
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t;
    cin>>t;
    
    while(t--){
        ll n;
        cin>>n;
        
        priority_queue<ll> pq;
        unordered_map<ll, ll> mp;
        
        for(ll i=0 ; i<n ; i++){
            ll val;
            cin>>val;
            mp[val]++;
        }
        
        for(auto &itr:mp)
        pq.push(itr.second);
        
        ll ans = n;
        
        while(pq.size()>1){
            ll top1 = pq.top();
            pq.pop();
            ll top2 = pq.top();
            pq.pop();
            
            ans -= 2;
            
            if(top1==0 || top2 == 0)
            break;
            
            top1--;
            top2--;
            
            if(top1 > 0)
            pq.push(top1);
            
            if(top2 > 0)
            pq.push(top2);
        }
        
        cout<<ans<<"\n";
    }
    
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details