HDU 1236 排名(Microsoft_zzt)
http://acm.hdu.edu.cn/showproblem.php?pid=1236
每题的分值,所以并不是最后的排名。给定录取分数线,请你写程序找出最后通过分数线的
考生,并将他们的成绩按降序打印。
< 1000 )、考题数M ( 0 < M < = 10 )、分数线(正整数)G;第2行排序给出第1题至第M题的正整数分值;以下N行,每行给出一
名考生的准考证号(长度不超过20的字符串)、该生解决的题目总数m、以及这m道题的题号
(题目号由1到M)。
当读入的考生人数为0时,输入结束,该场考试不予处理。
到低输出上线考生的考号与分数,其间用1空格分隔。若有多名考生分数相同,则按他们考
号的升序输出。
2 3 20
10 10 10
0
for(int j=1; j<=s[i].m; j++)
{
int x;
scanf("%d",&x);
s[i].add+=q[x].score;
}
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10;
int N,M,G; struct Students
{
char id[21];
int m;
int add;
} s[maxn]; int Com(char s1[maxn],char s2[maxn])
{
int len1 = strlen(s1);
int len2 = strlen(s2);
int m = min(len1,len2);
for(int i=0; i<m; i++)
{
if(s1[i]-s2[i]>0)
return 1;
else if(s1[i]-s2[i]==0)
continue;
else
return -1;
}
if(len1==len2)
return 0;
else if(len1>len2)
return 1;
else
return -1;
} struct Q
{
int score;
int num;
} q[maxn];
void display()
{
int sum=0;
for(int i=1; i<=N; i++)
{
if(s[i].add>=G)
sum++;
}
printf("%d\n",sum);
for(int i=1; i<=N; i++)
{
if(s[i].add>=G)
printf("%s %d\n",s[i].id,s[i].add);
}
} bool cmpScore( Students& a, Students& b)
{
if(a.add==b.add)
return Com(a.id,b.id)<=0;
else
return a.add>b.add;
} int main()
{
while(~scanf("%d",&N))
{
if(N==0)
break;
scanf("%d%d",&M,&G);
for(int i=1; i<=M; i++)
{
scanf("%d",&q[i].score);
}
for(int i=1; i<=N; i++)
{
s[i].add=0;
scanf("%s%d",s[i].id,&s[i].m);
for(int j=1; j<=s[i].m; j++)
{
int x;
scanf("%d",&x);
s[i].add+=q[x].score;
}
}
int L=1,R=N;
sort(s+L,s+R+1,cmpScore);
display();
}
return 0;
}
HDU 1236 排名(Microsoft_zzt)的更多相关文章
- 题解报告:hdu 1236 排名
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1236 Problem Description 今天的上机考试虽然有实时的Ranklist,但上面的排名 ...
- HDU 1236 排名(结构体+排序)
今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑 每题的分值,所以并不是最后的排名.给定录取分数线,请你写程序找出最后通过分数线的 考生,并将他们的成绩按降序打 ...
- hdu 1236 排名(排序)
题意:按成绩排序 思路:排序 #include<iostream> #include<stdio.h> #include<string.h> #include< ...
- hdu 1236 1.3.2排名
排名 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission ...
- HDOJ 1236 排名(练耐心题)
Problem Description 今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑 每题的分值,所以并不是最后的排名.给定录取分数线,请你写程序找出最后通 ...
- HDU 1236
水题~~但我做了很久: 题意:是中国人都懂了 思路:结构体排序: 以后要多用用重定义的排序手段,!!!!!多用!!多用!!多用!! #include<iostream> #include& ...
- 题解 HDU 3698 Let the light guide us Dp + 线段树优化
http://acm.hdu.edu.cn/showproblem.php?pid=3698 Let the light guide us Time Limit: 5000/2000 MS (Java ...
- 1236 hdu排名
Problem Description 今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑 每题的分值,所以并不是最后的排名.给定录取分数线,请你写程序找出最后通 ...
- HDU 1285 确定比赛排名 (数组实现 )
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1285 确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) ...
随机推荐
- UOJ 【UR #5】怎样跑得更快
[UOJ#62]怎样跑得更快 题面 这个题让人有高斯消元的冲动,但肯定是不行的. 这个题算是莫比乌斯反演的一个非常巧妙的应用(不看题解不会做). 套路1: 因为\(b(i)\)能表达成一系列\(x(i ...
- python五十六课——正则表达式(常用函数之compile())
2).compile(regex,[flags=0]):返回一个Pattern对象(认为:它内部已经封装了一套regex和flags) 可以再通过Pattern对象继续调用match函数(此时只需要传 ...
- 转://UDEV简介及配置过程
在Linux环境下安装Oracle11g RAC时,OS层面配置好多路径软件后(multipath),下一步就需要配置udev或asmlib来处理共享分区(Lun),以便Orace ASM能够看到这些 ...
- 2.1 View与ViewGroup的概念
http://www.runoob.com/w3cnote/android-tutorial-view-viewgroup-intro.html UI Overview 在Android APP中,所 ...
- Python基础(6)——装饰器
装饰器: def w1(func): def inner(): # 验证1 # 验证2 # 验证3 return func() return inner @w1 def f1(): print 'f1 ...
- ES6中Object.assign() 方法
ES6中Object.assign() 方法 1. 对象合并Object.assign 方法用于对象的合并,将源对象(source)的所有可枚举属性,复制到目标对象上.如下代码演示: var targ ...
- linux中断源码分析 - 概述(一)
本文为原创,转载请注明:http://www.cnblogs.com/tolimit/ 关于中断和异常 一般在书中都会把中断和异常一起说明,因为它们具有相同的特点,同时也有不同的地方.在CPU里,中断 ...
- Tensorflow[目录结构]
1 - Tensorflow源码目录结构 基于2018年5月28日github的tensorflow源码,即1.8版本 第一层: tensorflow: 核心代码目录. third_party:第三方 ...
- eclipse 报错Version 1.6.0_45 of the JVM is not suitable for this product. Version:1.7 or greater is required
最近离职来了一家新公司,之前的公司的开发IDE用的是IntelliJIDEA和SpringSourceToolSuit,自己在家里用的也是MyEclipse,所以使用eclipse的经验还是不足.结果 ...
- mysqldump备份数据库
1. 备份数据库-->sql文件 mysqldump -h192.168.1.100 -uuser -p123 --databases name > /tmp/databasedump.s ...