//1055. The World's Richest (25)
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct people
{
char name[10];
int age;
int worth;
}People[100000];
bool cmp(people a, people b)
{
if(a.worth!=b.worth)
return a.worth>b.worth;
else if(a.age!=b.age) return a.age<b.age;
else return strcmp(a.name,b.name)<0;
}
int main()
{
int N=0,K=0,M=0;
int Amin=0,Amax=0;
int i=0,j=0,x=0,flag=0;
scanf("%d %d",&N,&K);
while(i<N)
{
scanf("%s %d %d",People[i].name,&People[i].age,&People[i].worth);
i++;
}
sort(People, People+N, cmp);
i=0;
while(i<K)
{
scanf("%d %d %d",&M,&Amin,&Amax);
printf("Case #%d:\n",i+1);
x = 0;
j = 0;
while(j<N)
{
if(People[j].age>=Amin && People[j].age<=Amax && x<M)
{
printf("%s %d %d\n",People[j].name,People[j].age,People[j].worth);
x++;
}
j++;
}
if(x == 0)
printf("None\n");
i++;
}
return 0;
}
1055. The World's Richest (25)
最新推荐文章于 2021-08-22 16:32:31 发布