#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int N=100010;
struct people{
string name;
int age;
int wealth;
bool operator < (const people& t) const{
if(wealth!=t.wealth) return wealth>t.wealth;
if(age!=t.age) return age<t.age;
return name<t.name;
}
}peoples[N];
int main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
string name;
int age,wealth;
cin>>name>>age>>wealth;
peoples[i]={name,age,wealth};
}
sort(peoples,peoples+n);
for(int i=1;i<=m;i++){
int num,amin,amax;
cin>>num>>amin>>amax;
vector<people> ans;
for(int j=0;j<n&#j++){
if(peoples[j].age>=amin&&peoples[j].age<=amax){
ans.push_back(peoples[j]);
num--;
}
}
printf("Case #%d:\n",i);
if(ans.size()>0){
sort(ans.begin(),ans.end());
for(int j=0;j<ans.size();j++){
cout<<ans[j].name<<" "<<ans[j].age<<" "<<ans[j].wealth<<endl;
}
}
else
cout<<"None"<<endl;
}
return 0;
}
pat 甲级 1055 The World‘s Richest
最新推荐文章于 2024-07-19 22:36:19 发布