HDU-1236-排名
来源:互联网 发布:人生真相知乎 编辑:程序博客网 时间:2024/04/29 18:46
#include<iostream>#include<string>#include<queue>#include<map>#include<set>#include<vector>#include<algorithm>#include<cstdio>#include<cstring>using namespace std;/* 题目很简单,考查的就是结构体自定义排序问题;*/int n,m,G,t,q;int score[15];// 定义结构体;typedef struct{ char id[25]; int total=0;}NODE;// 自定义排序;bool cmp(NODE x,NODE y){ if(x.total!=y.total) return x.total>y.total; else return strcmp(x.id,y.id)<0; // 因为这个WA几次,真是C/C++把自己给弄晕了。。。}int main(){ while(~scanf("%d",&n)){ if(!n) break; NODE stu[1005]; scanf("%d%d",&m,&G); int cnt=0; for(int i=1;i<=m;i++) scanf("%d",&score[i]); // 存各题所对应的分数 for(int i=0;i<n;i++){ scanf("%s",&stu[i].id); // 存学生学号 scanf("%d",&t); for(int j=0;j<t;j++){ scanf("%d",&q); stu[i].total+=score[q]; // 存所过题目的总分数; } if(stu[i].total>=G) cnt++; // 计数所有通过的人数; } sort(stu,stu+n,cmp); // 调用函数库里的排序; printf("%d\n",cnt); for(int i=0;i<cnt;i++){ printf("%s %d\n",stu[i].id,stu[i].total); } } return 0;}
0 0
- HDU 1236 排名
- HDU-1236 排名
- HDU 1236 ( 排名 )
- hdu 题目1236 排名
- hdu-1236--排名
- hdu 1236 排名
- hdu 1236 排名
- HDU 1236 排名
- hdu-1236-排名
- HDU 1236 排名
- HDU 题目1236 排名
- hdu 1236 排名
- hdu 1236 排名
- hdu-1236-排名
- hdu 1236 排名
- HDU 1236 排名
- hdu 1236 排名
- hdu 1236 排名
- UVa1024 Fun Game
- Android WebView常见问题总结
- Windows 7 IIS (HTTP Error 500.21 - Internal Server Error)解决
- s2
- s3
- HDU-1236-排名
- 说
- OCR破坏与恢复
- JAVA基础----网络编程
- Swift字典总结
- 梯度法(SGD)、拟牛顿法(LBFGS)与共轭梯度法(CG)
- 将数据文件恢复到不同的路径
- spring生命周期init-method destroy-methd 不要和prototype一起用
- 【转】理解矩阵(一)