PAT 1062. Talent and Virtue
来源:互联网 发布:笔记本无线mac地址修改 编辑:程序博客网 时间:2024/06/13 11:43
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1062
题解:
代码:
#include<cstdio>#include<iostream>#include<cstring>#include<cmath>#include<string>#include<vector>#include<algorithm>using namespace std;#define MAX 100005struct stu{ string id; int d; int c; int summ;}stu[4][MAX];bool cmp(const struct stu &a,const struct stu &b){ if(a.summ>b.summ) return true; else if(a.summ==b.summ) { if(a.d>b.d) return true; else if(a.d==b.d) return a.id<b.id; else return false; } else return false;}int main(){ int n,l,h; int len[4]; memset(len,0,sizeof(len)); string id; char ch[10]; int d,c; scanf("%d%d%d",&n,&l,&h); for(int i=0;i<n;++i) { scanf("%s%d%d",ch,&d,&c); id=string(ch); if(d<l||c<l) continue; if(d>=h&&c>=h) { stu[0][len[0]].id=id; stu[0][len[0]].d=d; stu[0][len[0]].c=c; stu[0][len[0]].summ=d+c; ++len[0]; } else if(d>=h) { stu[1][len[1]].id=id; stu[1][len[1]].d=d; stu[1][len[1]].c=c; stu[1][len[1]].summ=d+c; ++len[1]; } else if(d<h&&d>=c) { stu[2][len[2]].id=id; stu[2][len[2]].d=d; stu[2][len[2]].c=c; stu[2][len[2]].summ=d+c; ++len[2]; } else { stu[3][len[3]].id=id; stu[3][len[3]].d=d; stu[3][len[3]].c=c; stu[3][len[3]].summ=d+c; ++len[3]; } } for(int i=0;i<4;++i) sort(stu[i],stu[i]+len[i],cmp); printf("%d\n",len[0]+len[1]+len[2]+len[3]); for(int i=0;i<4;++i) for(int j=0;j<len[i];++j) printf("%s %d %d\n",stu[i][j].id.c_str(),stu[i][j].d,stu[i][j].c); return 0;}
来源:http://blog.csdn.net/acm_ted/article/details/20148217
0 0
- PAT 1062. Talent and Virtue
- PAT 1062. Talent and Virtue
- PAT--1062. Talent and Virtue
- 1062. Talent and Virtue (25)-PAT
- pat 1062. Talent and Virtue (25)
- 【PAT】1062. Talent and Virtue (25)
- PAT (Advanced) 1062. Talent and Virtue (25)
- PAT A 1062. Talent and Virtue (25)
- PAT 1062. Talent and Virtue (25)
- 【PAT甲级】1062. Talent and Virtue (25)
- PAT-A 1062. Talent and Virtue (25)
- PAT甲级1062. Talent and Virtue (25)
- PAT-A-1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)-PAT甲级
- PAT 甲级 1062. Talent and Virtue (25)
- PAT甲级 1062. Talent and Virtue (25)
- PAT-Talent and Virtue (25)
- 1062. Talent and Virtue
- spring MVC视图解析
- 并行与并发的区别
- androidpn环境测试
- C语言经典算法100例-011-兔子问题
- Linux 指令篇:文件管理--which
- PAT 1062. Talent and Virtue
- Android开发学习笔记:浅谈WebView
- Cloud Zoom是一个图像放大jQuery插件,
- Android获取dialog自定义布局中的控件(从控件中获得参数)
- 漫画形象诞生记
- iOS图片合成————(拍照换发)
- /lib/ld-linux.so.3: No such file or directory
- Android屏幕适配
- 题目1047:素数判定