PAT(甲级)1055. The World's Richest (25)
来源:互联网 发布:中企动力大数据推广 编辑:程序博客网 时间:2024/06/04 18:42
题目:https://www.patest.cn/contests/pat-a-practise/1055
代码:
#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>using namespace std;struct rich{char name[10];int age;int wealth;}s[100010],sele[100010];int age[100010]={0};bool cmp(rich a,rich b){if(a.wealth!=b.wealth) return a.wealth>b.wealth;else if(a.age!=b.age) return a.age<b.age;else return strcmp(a.name,b.name)<0;}int main(){int m,n;scanf("%d%d",&n,&m);for(int i=0;i<n;i++){scanf("%s%d%d",&s[i].name,&s[i].age,&s[i].wealth);}sort(s,s+n,cmp);int t=0;for(int i=0;i<n;i++){if(age[s[i].age]<100){ age[s[i].age]++; sele[t++]=s[i];}}int temp,min,max;for(int i=1;i<=m;i++){ scanf("%d%d%d",&temp,&min,&max); printf("Case #%d:\n",i); int count=0; for(int j=0;j<t&&count<temp;j++){ if(sele[j].age>=min&&sele[j].age<=max){ printf("%s %d %d\n",sele[j].name,sele[j].age,sele[j].wealth); count++; } } if(count==0){ printf("None\n"); }} system("pause");}
0 0
- PAT(甲级)1055. The World's Richest (25)
- 1055. The World's Richest (25)-PAT甲级真题
- 【PAT甲级】1055. The World's Richest (25)
- 1055. The World's Richest (25) PAT甲级
- PAT甲级练习1055. The World's Richest (25)
- PAT甲级1055. The World's Richest (25)
- PAT 甲级 1055. The World's Richest (25)
- PAT甲级 1055. The World's Richest (25)
- 【PAT】1055. The World's Richest (25)
- pat 1055. The World's Richest (25)
- pat 1055. The World's Richest (25)
- PAT: 1055. The World's Richest (25)
- PAT 1055. The World's Richest (25)
- pat 1055. The World's Richest (25)
- PAT 1055. The World's Richest (25)
- PAT 1055. The World's Richest (25)
- <PAT>1055. The World's Richest
- PAT 1055. The World's Richest
- 476. Number Complement
- ZCMU—1854
- 欢迎使用CSDN-markdown编辑器
- AsyncTask小结
- Oracle 12c CC安装部署攻略 (中)
- PAT(甲级)1055. The World's Richest (25)
- 异或实现交换两个数
- 佛山客户上线ERP
- 学习docker
- UVa272
- 算法之路三:HDU OJ:2016
- Linux 中的各种栈:进程栈 线程栈 内核栈 中断栈
- 第四十八讲项目7.1-找数字
- 1.26.8