View Code of Problem 5

// ConsoleApplication2.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<stdio.h>

int _tmain(int argc, _TCHAR* argv[])
{
	int T;
	int m,n,i,x,j;
	int a[100010][2];
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d",&m,&n);
		for(i=1;i<=m;i++)
			scanf("%d%d",&a[i][0],&a[i][1]);
		for(j=0;j<n;j++)
		{
			x=1;
			for(i=1;i<=m;i++)
			{
				if(a[i][0]>a[x][0] || a[i][0]==a[x][0] && a[i][1]>a[x][1])
				{
					x=i;
				}
			}
			printf("%d",x);
			a[x][0]=0;a[x][1]=0;
			printf(j==n-1?"\n":" ");
		}
	}
	return 0;
}


/*
Main.c:4:20: fatal error: stdafx.h: No such file or directory
 #include "stdafx.h"
                    ^
compilation terminated.
*/

Double click to view unformatted code.


Back to problem 5