1055. The World's Richest (25) PAT甲级
来源:互联网 发布:网络录像机怎么联网 编辑:程序博客网 时间:2024/05/16 01:51
传送门
#include<stdio.h>#include<algorithm>#include<math.h>#include<string.h>using namespace std;#define MAX_N 100100struct Person{ char name[10]; int age; int wealth;}p[MAX_N],valid[MAX_N];int n,k;int age[MAX_N];bool cmp(struct Person a,struct Person b){ if(a.wealth!=b.wealth) return a.wealth>b.wealth; if(a.age!=b.age) return a.age<b.age; return strcmp(a.name,b.name)<0;}int main(){ scanf("%d%d",&n,&k); for(int i=0;i<n;i++){ scanf("%s %d%d",p[i].name,&p[i].age,&p[i].wealth); } sort(p,p+n,cmp); int num=0; for(int i=0;i<n;i++){ if(age[p[i].age]<100){ age[p[i].age]++; valid[num++]=p[i]; } } int m,amin,amax; for(int i=1;i<=k;i++){ scanf("%d%d%d",&m,&amin,&amax); printf("Case #%d:\n",i); int count=0; for(int j=0;j<num&&count<m;j++){ if(valid[j].age>=amin&&valid[j].age<=amax){ printf("%s %d %d\n",valid[j].name,valid[j].age,valid[j].wealth); count++; } } if(count==0){ printf("None\n"); } }}
0 0
- 1055. The World's Richest (25)-PAT甲级真题
- 【PAT甲级】1055. The World's Richest (25)
- 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
- HDU 2509 Be the Winner(博弈论入门题)
- 关于textarea无法居中的问题
- C#编程基础->XML系列导航
- Leetcode 475 -Heaters(二分 or 贪心)
- scrapy-response.xpath中无法获取标签内容的问题
- 1055. The World's Richest (25) PAT甲级
- 微信小程序--熟悉项目结构
- 广播BroadCastReceiver
- Unity 延迟执行一段代码的实现比较好的方式
- 多模型旋转互换的脚本分析
- Mybatis动态插入数据(使用trim标签)
- 笨方法学Python习题6 在Python3
- C# 绘图
- 数组