-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpat1055.cpp
67 lines (62 loc) · 1.34 KB
/
pat1055.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <string.h>
using namespace std;
#define INF -1000100
struct Rich{
char name[10];
int age;
long long worth;
bool operator < (const Rich &A) const{
if(worth!=A.worth)
return worth>A.worth;
else if(age!=A.age)
return age<A.age;
else{
int tmp=strcmp(name,A.name);
return tmp<0?true:false;
}
}
} rich[100010];
queue<Rich> q;
long long n;
int k;
void output(int size,int min,int max,int num,int newSize){
printf("Case #%d:\n",num);
bool flag=false;
for(long long i=0;i<newSize;i++){
if(rich[i].age>=min&&rich[i].age<=max){
printf("%s %d %lld\n",rich[i].name,rich[i].age,rich[i].worth);
size--;
flag=true;
}
if(!size) break;
}
if(!flag) printf("None\n");
return;
}
int main(){
while(scanf("%lld%d",&n,&k)!=EOF){
for(long long i=0;i<n;i++)
scanf("%s %d %lld",rich[i].name,&rich[i].age,&rich[i].worth);
sort(rich,rich+n);
int newSize=n;
int ageCount[210]={0};
for(int i=0;i<n;i++){
int tmp=rich[i].age;
ageCount[tmp]++;
if(ageCount[tmp]>100){
rich[i].worth=INF;
newSize--;
}
}
sort(rich,rich+n);
for(int i=1;i<=k;i++){
int size,min,max;
scanf("%d%d%d",&size,&min,&max);
output(size,min,max,i,newSize);
}
}
return 0;
}