Help me in solving TRIPLETMIN problem

My issue

what is wrong in my code it give me wrong answer.

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	//shri hari
	
	int t;
	cin>>t;
	
	
	while(t--)
	{
	    int n,q,ja;
	    cin>>n>>q;
	    vector<long long> v,que;
	    
	    for(int i=0;i<n;i++)
	    {
	        cin>>ja;
	        v.push_back(ja);
	    }
	    
	    for(int i=0;i<q;i++)
	    {
	        cin>>ja;
	        que.push_back(ja);
	    }
	    
	    sort(v.begin(),v.end());
	    
	    vector<long long int> ans(n,INT_MAX);
	    
	    long long int temp,count=n-1,store=0,pre=0;
	    
	    for(int i=0;i<n;i++)
	    {
	        store += count*(count-1)/2;
	        ans[i]=store;
	        count--;
	        if(count<2)break;
	    }
	    
	    long long int find;
	    
	    for(int i=0;i<q;i++)
	    {
	        find=que[i];
	        
	        cout<<v[lower_bound(ans.begin(),ans.end(),find) - ans.begin()]<<endl;
	        
	       // cout<<ans[que[i]-1]<<endl;
	    }
	}
	return 0;
}

Problem Link: TRIPLETMIN Problem - CodeChef

In this ( int n,q,ja ) line you have to take int long long because query is greater than 1e9 so your input get overflow.
Hope it might be helpful.

Thanks