1055 The World’s Richest (25 分)
#include <iostream>
#include <algorithm>
using namespace std;
struct p{
string name;
int age, value;
}a[100100];
bool cmp(p x, p y){
if(x.value != y.value)
return x.value > y.value;
else if(x.age != y.age)
return x.age < y.age;
return x.name < y.name;
}
int main(){
ios::sync_with_stdio(false);
int n, k, x, y, m;
cin >> n >> k;
for(int i = 0; i < n; ++i)
cin >> a[i].name >> a[i].age >> a[i].value;
sort(a, a + n, cmp);
for(int i = 1; i <= k; ++i){
int ret = 0;
cin >> m >> x >> y;
cout << "Case #" << i << ":" << endl;
for(int j = 0; j < n; ++j){
if(a[j].age >= x && a[j].age <= y){
cout << a[j].name <<" "<< a[j].age <<" "<< a[j].value <<endl;
ret++;
}
if(ret == m)
break;
}
if(ret == 0)
cout << "None" <<endl;
}
}