View Code of Problem 5

#include <iostream>
using namespace std;
int t,m,n;
int main(){
	cin>>t;
	while(t--){
		cin>>n>>m;
		int a[n+10];
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			a[i]=x*10000+y;
		}
//		int len=0;
		for(int i=0;i<m;i++){
			int maxx=i;
			for(int j=0;j<n;j++){
				if(a[j]>a[maxx])
					maxx=j;
			}
			int t=a[i];a[i]=a[maxx];a[maxx]=t;
			if(i==m-1)
				cout<<maxx+1<<endl;
			else
				cout<<maxx+1<<" ";
		}
		
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 5