View Code of Problem 5

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--){
        int n,m;
        int k=0;
        cin>>n>>m;
        pair<int,int> a[n];
        for(int i = 0; i < n;i++){
            cin >> a[i].first >>a[i].second;
        }
       for(int i=0;i < m;i++){
        for(int j=0;j <n;j++){
            if(a[k]<a[j]) k=j;
        }
        cout<<k+1;
        if(i<m-1) cout<<" ";
        a[k].first=0;
       }
       cout<<endl;
}
}

Double click to view unformatted code.


Back to problem 5