Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
149215664 Practice:
idonthatephy
1650C - 31 C++17 (GCC 7-32) Runtime error on test 4 686 ms 12176 KB 2022-03-11 09:08:07 2022-03-11 09:08:07
→ Source
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"


using namespace std;
bool comp(pair<ll,ll>a,pair<ll,ll>b){
    if(a.second>b.second){
        return false;
    }
    else{
        return true;
    }
}
bool comp1(pair<ll,ll>a,pair<ll,ll>b){
    if(a.first<b.first){
        return true;
    }
    return false;
}
int main(){
 //ios_base::sync_with_stdio(false);
   // cin.tie(NULL);
int t;
cin>>t;
while(t--){
    string v;
   // cin>>v;
    ll n,m;
    cin>>n>>m;
//    cout<<m<<endl;
    //map<ll,ll>num;
    map<ll,ll>ind;
    ll x,y;
    vector<pair<ll,ll>>p;
    for(ll i=1;i<=m;i++){
        cin>>x;
        cin>>y;
        //m.insert({x,y});
        p.push_back({x,y});
        //num[x]=y;
        ind[x]=i;
        
    }
    sort(p.begin(),p.end(),comp);
    // for(auto i:p){
    //     cout<<i.first<<endl;
    //     cout<<i.second<<endl;
    // }
    while(p.size()!=2*n){
        p.pop_back();
    }
    sort(p.begin(),p.end(),comp1);
    ll j=p.size()-1;
    ll sum=0;
    for(ll i=0;i<p.size();i++){
        sum+=p[i].second;
    }
    cout<<sum<<endl;
    for(ll i=0;i<p.size()/2;i++){
        cout<<ind[p[i].first]<<" "<<ind[p[j].first]<<endl;
        //sum+=p[i].second+p[j].second;
        j--;


    }
    //cout<<sum<<endl;

}
return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details