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=1;i<=n;i++){
			int x,y;
			cin>>x>>y;
			a[i]=x*10000+y;
		}
//		int len=0;
		for(int i=1;i<=m;i++){
			int maxx=i;
			for(int j=1;j<=n;j++){
				if(a[j]>a[maxx])
					maxx=j;
			}
//			int t=a[i];a[i]=a[maxx];a[maxx]=t;
			if(i==m)
				cout<<maxx<<endl;
			else
				cout<<maxx<<" ";
			a[maxx]=-1;
		}
		
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 5