LOWSUM - Getting TLE! How to speed up?

I was trying to implement the solution by following the editorial.

I am still getting a TLE. What am I missing?

#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;

class compare
{
public:
    bool operator()(int a, int b)
    {
        return a>b;
    }
};

int main()
{
    int T,K,Q;
    vector<int> A,B,q;
    priority_queue<int, vector<int> , compare> PQ;      //min PQ
    scanf("%d",&T);

    while(T--)
    {
        scanf("%d %d",&K,&Q);

        A.resize(K);B.resize(K);q.resize(Q);

        for(int i= 0;i<K;++i)
            scanf("%d",&A[i]);

        for(int i=0;i<K;++i)
            scanf("%d",&B[i]);

        for(int i=0;i<Q;++i)
            scanf("%d",&q[i]);

        sort(A.begin(),A.end());
        sort(B.begin(),B.end());

        

        for(int i=0;i<Q;++i)
        {
            while(!PQ.empty())PQ.pop();
            int q_value=q[i];

            int j=0, nth_sum=0;

            while(q_value>0)
            {
                for(int i=0;i<K;++i)
                    PQ.push(A[i]+B[j]);     //push A[0..K-1] + B[j] to PQ j<- 0 to q_value-1

                nth_sum=PQ.top();           //find min sum
                PQ.pop();
                q_value--;
                j++;                        //next element of B[]
            }

            printf("%d\n",nth_sum);
        }
    }
}

Check constraints

1 ≤ Ai ≤ 10^18 ( for i = 1 to K )

1 ≤ Bi ≤ 10^18 ( for i = 1 to K )