View Code of Problem 5

#include<stdio.h>
int main()
{
	int t;
	int n,m;
	int k=0;
	int a[1001][2];
	scanf("%d",&t);
	for(int i=1;i<=t;i++)
	{
		k=0;
		scanf("%d %d",&n,&m);
		for(int j=0;j<n;j++)
		{
			scanf("%d %d",&a[j][0],&a[j][1]);
		}
		for(int g=0;g<m;g++)
		{
			for(int j=0;j<n;j++)
			{
				if(a[k][0]<a[j][0])k=j;
				if(a[k][0]==a[j][0]&&a[k][1]<a[j][1])k=j;			
			}
			a[k][0]=-1; 	
			if(g==m-1)printf("%d",k+1);
			else printf("%d ",k+1);
		}
		printf("\n");
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 5