View Code of Problem 5

#include <stdio.h>
#include <string.h>
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int a[10000],m,n,t,i,j;
		scanf("%d %d",&n,&m);
		for(i=0;i<n;i++){
			int a1,b;
			scanf("%d %d",&a1,&b);
			a[i]=a1*100000+b;
		}
		for(i=0;i<m;i++){
			int max=0;
			for(j=0;j<n;j++){
				if(a[j]>a[max])
				max=j;
			}
			if(i==0) printf("%d",max+1);
		    else printf(" %d",max+1);
		    a[max]=-1;
		}
		printf("\n");
	}

}

Double click to view unformatted code.


Back to problem 5