1055

#include 
#include 
#include 
using namespace std;
const int maxn = 100010;
struct student{
	char name[10];
	int age;
	int w;
}stu[maxn],valid[102];
bool cmp(student a,student b)
{
	if(a.w != b.w)  return a.w > b.w;
	else if(a.age != b.age) return a.age < b.age;
	else return strcmp(a.name,b.name) < 0;
}
int main()
{
	int n,k,m,up,down;
	scanf("%d %d",&n,&k);
	for(int i = 0; i < n; i++)
	{
		scanf("%s %d %d",stu[i].name,&stu[i].age,&stu[i].w);
		
	}
		sort(stu,stu + n,cmp);
	for(int j = 1; j <= k; j++)
	{
		    int num = 0;
	    	fscanf(fp,"%d %d %d",&m,&down,&up);
			printf("Case #%d:\n",j);
		    for(int i = 0; i < n; i++)
		    {
		    	if(num == 100 || num == m) break; 
		    	if(stu[i].age <= up && stu[i].age >= down)
		    	{
		    		valid[num++] = stu[i];
		    	}
		    }
		    if(num == 0)
		    {
		    	printf("None\n");
		    	continue;
		    }
		
			for(int t = 0; t < num; t++)
			{
				if(valid[t].age <= up && valid[t].age >= down)
				printf("%s %d %d\n",valid[t].name,valid[t].age,valid[t].w);
			}
	}
	
	return 0;
}

 

你可能感兴趣的:(1055)