题目1014:排名
来源:互联网 发布:极限挑战 黄磊 知乎 编辑:程序博客网 时间:2024/06/05 15:25
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node{
char id[100]; // 学号
int score; // 得到的总分
}stu[1000];
int cmp(node a,node b){
if(a.score!=b.score) return a.score>b.score;
else{
int tmp=strcmp(a.id,b.id);
return tmp<0;
}
}
int main()
{
int N;
while(scanf("%d",&N)!=EOF){
if(N==0) break;
int M,G;
scanf("%d%d",&M,&G);
int pro[10]; // 题号为i的分值
for(int i=1;i<=M;i++) scanf("%d",&pro[i]);
for(int i=0;i<N;i++){
int m;
scanf("%s%d",stu[i].id,&m);
stu[i].score=0;
for(int j=0;j<m;j++){
int c;
scanf("%d",&c);
stu[i].score+=pro[c];
}
}
sort(stu,stu+N,cmp);
int cnt=0;
for(int i=0;i<N;i++){
if(stu[i].score>=G) cnt++;
}
printf("%d\n",cnt);
for(int i=0;i<cnt;i++){
printf("%s %d\n",stu[i].id,stu[i].score);
}
}
return 0;
}
#include<string.h>
#include<algorithm>
using namespace std;
struct node{
char id[100]; // 学号
int score; // 得到的总分
}stu[1000];
int cmp(node a,node b){
if(a.score!=b.score) return a.score>b.score;
else{
int tmp=strcmp(a.id,b.id);
return tmp<0;
}
}
int main()
{
int N;
while(scanf("%d",&N)!=EOF){
if(N==0) break;
int M,G;
scanf("%d%d",&M,&G);
int pro[10]; // 题号为i的分值
for(int i=1;i<=M;i++) scanf("%d",&pro[i]);
for(int i=0;i<N;i++){
int m;
scanf("%s%d",stu[i].id,&m);
stu[i].score=0;
for(int j=0;j<m;j++){
int c;
scanf("%d",&c);
stu[i].score+=pro[c];
}
}
sort(stu,stu+N,cmp);
int cnt=0;
for(int i=0;i<N;i++){
if(stu[i].score>=G) cnt++;
}
printf("%d\n",cnt);
for(int i=0;i<cnt;i++){
printf("%s %d\n",stu[i].id,stu[i].score);
}
}
return 0;
}
0 0
- 题目1014:排名
- 题目1014:排名
- 题目1014:排名
- 题目1014:排名
- 题目1014:排名
- 题目1014:排名
- 题目1014:排名
- 题目1014:排名
- 题目1014:排名
- 九度 题目1014:排名
- 九度OJ 题目1014:排名
- 九度OJ题目1014:排名
- 九度OJ题目1014:排名
- 九度OJ:题目 1014 排名
- 九度OJ-题目1014 排名
- 题目1014:排名 九度OJ
- hdu 题目1236 排名
- HDU 题目1236 排名
- 隐式类类型转换
- java设计模式——单例(Singleton)模式
- 查看Linux内核版本的命令
- WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction
- Redis持久化之大数据服务暂停问题
- 题目1014:排名
- 消费者调查的作用
- unresolved external symbol解决方法
- XCODE使用git
- 关于ListView中notifyDataSetChanged()刷新数据不更新原因
- HDU 4737 A Bit Fun
- Linux 搭建SVN 服务器
- Java中的连字符
- 矩形类