Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 27):
#include<bits/stdc++.h>

using namespace std;


struct cmp{

    bool operator()(vector<int> &a,vector<int> &b)
    {
        return a[0] < b[0];
    }

};



void solve()
{
    int n,m;
    cin >> n;
    cin >> m;

    vector<int> a(n);
    vector<int> b(m);

    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<m;i++)
        cin >> b[i];


    priority_queue<vector<int>,vector<vector<int>>,cmp> pq;
    
    unordered_map<int,int> cnta;
    unordered_map<int,int> cntb;

    for(int t:a)
    {
        if(cnta.find(t) == cnta.end())
            cnta[t] = 1;
        

        else
            cnta[t]++;
    }


    for(int t:b)
    {
        if(cntb.find(t) == cntb.end())
            cntb[t] = 1;
        else
            cntb[t]++;
    }

    unordered_map<int,int> gap;
    for(auto &it:cnta)
    {
        if(cntb.find(it.first) == cntb.end())
            gap[it.first] = -it.second;
        else    
            gap[it.first] = cntb[it.first] - it.second;
    }   

    for(auto &it:cntb)
    {
        if(cnta.find(it.first) == cnta.end())
            gap[it.first] = cntb[it.first];
    }


    for(auto &it:gap)
    {
        pq.push({it.first,it.second});
    }



    for(int i=0;i<n-m;i++)
    {

        //cout << pq.size() << "\n";

        while(!pq.empty() && (pq.top()[1] == 0 || pq.top()[1] != gap[pq.top()[0]]))
        {
            pq.pop();
        }

        

        if(pq.empty())
        {
            cout << "no"  << "\n";
            return;
        }
        
        int num = pq.top()[0];
        int cnt = pq.top()[1];
        //cout << num << cnt << "\n";

        if(cnt < 0)
        {
            cout << "no" << "\n";
            return;
        }

        
        pq.pop();
        if(cnt - 1 != 0)
            pq.push({num,cnt-1});
        gap[num] = cnt-1;
        
        if(gap.find(num/2) == gap.end())
            gap[num/2] = 1;
        else
            gap[num/2]++;

        
        if(gap.find((num+1)/2) == gap.end())
            gap[(num+1)/2] = 1;
        else
            gap[(num+1)/2]++;

        
        if(gap[num/2] != 0)
        pq.push({num/2,gap[num/2]});

        
        if(gap[(num+1)/2] != 0)
        pq.push({(num+1)/2,gap[(num+1)/2]});
    }


    while(!pq.empty() && (pq.top()[1] == 0 || pq.top()[1] != gap[pq.top()[0]]))
    {
        pq.pop();
    }



    if(pq.empty())
        cout << "yes" << "\n";
    else
        cout << "no" << "\n";

}



int main()
{
    int t;
    cin >> t;

    while(t--)
        solve();


    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

using namespace std;

using ll = long long;

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
		return x; 
	}
	size_t operator () (uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); // 时间戳
		return splitmix64(x + FIXED_RANDOM);
	}
};



struct cmp{

    bool operator()(vector<ll> &a,vector<ll> &b)
    {
        return a[0] < b[0];
    }

};



void solve()
{
    int n,m;
    cin >> n;
    cin >> m;

    vector<ll> a(n);
    vector<ll> b(m);

    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<m;i++)
        cin >> b[i];


    priority_queue<vector<ll>,vector<vector<ll>>,cmp> pq;
    
    unordered_map<ll,ll,custom_hash> cnta;
    unordered_map<ll,ll,custom_hash> cntb;

    for(int t:a)
    {
        if(cnta.find(t) == cnta.end())
            cnta[t] = 1;
        

        else
            cnta[t]++;
    }


    for(int t:b)
    {
        if(cntb.find(t) == cntb.end())
            cntb[t] = 1;
        else
            cntb[t]++;
    }

    unordered_map<ll,ll,custom_hash> gap;
    for(auto &it:cnta)
    {
        if(cntb.find(it.first) == cntb.end())
            gap[it.first] = -it.second;
        else    
            gap[it.first] = cntb[it.first] - it.second;
    }   

    for(auto &it:cntb)
    {
        if(cnta.find(it.first) == cnta.end())
            gap[it.first] = cntb[it.first];
    }


    for(auto &it:gap)
    {
        pq.push({ (long long)it.first,it.second});
    }



    for(int i=0;i<n-m;i++)
    {

        //cout << pq.size() << "\n";

        while(!pq.empty() && (pq.top()[1] == 0 || pq.top()[1] != gap[pq.top()[0]]))
        {
            pq.pop();
        }

        

        if(pq.empty())
        {
            cout << "no"  << "\n";
            return;
        }
        
        ll num = pq.top()[0];
        ll cnt = pq.top()[1];
        //cout << num << cnt << "\n";

        if(cnt < 0)
        {
            cout << "no" << "\n";
            return;
        }

        
        pq.pop();
        if(cnt - 1 != 0)
            pq.push({num,cnt-1});
        gap[num] = cnt-1;
        
        if(gap.find(num/2) == gap.end())
            gap[num/2] = 1;
        else
            gap[num/2]++;

        
        if(gap.find((num+1)/2) == gap.end())
            gap[(num+1)/2] = 1;
        else
            gap[(num+1)/2]++;

        
        if(gap[num/2] != 0)
        pq.push({num/2,gap[num/2]});

        
        if(gap[(num+1)/2] != 0)
        pq.push({(num+1)/2,gap[(num+1)/2]});
    }


    while(!pq.empty() && (pq.top()[1] == 0 || pq.top()[1] != gap[pq.top()[0]]))
    {
        pq.pop();
    }



    if(pq.empty())
        cout << "yes" << "\n";
    else
        cout << "no" << "\n";

}



int main()
{
    int t;
    cin >> t;

    while(t--)
        solve();


    return 0;
}