View Code of Problem 5

#include<iostream>
using namespace std;

int main(){
  int t,a[10000][2],b[10000],n,m,k,temp,i,j;
  int s=0;
  cin>>t;
  while(t--){
    cin>>n>>m;
    for(i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
    }
    for(i=0;i<m;i++){
	  k = 0;
      for(j=0;j<n;j++){
        if(a[j][0]>a[k][0])
          k = j;
		else if (a[j][0]==a[k][0]){
			if(a[j][1]>a[k][1])
					  k = j;
		}
      }
	  a[k][0] = -1;
	  if(i != m-1)
		  cout<<k+1<<' ';
	  else
		  cout<<k+1;
    } 
	cout<<endl;
  }
}

Double click to view unformatted code.


Back to problem 5