题目不难,但是需要对数据进行处理,我的代码有些冗长,希望以后能改进。。。

主要思路是先算总的时间,然后进行对比,将做同样题数的前一半的人筛选出来。

/状态:AC/

Description

“Point, point, life of student!”        This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.        There are 5 problems in this final exam. And I will give you 100 points if you can solve all 5 problems; of course, it is fairly difficulty for many of you. If you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former(前者) only when your rank is in the first half of all students who solve 4 problems). Analogically(以此类推), you can get 85、80、75、70、65、60. But you will not pass this exam if you solve nothing problem, and I will mark your score with 50.        Note, only 1 student will get the score 95 when 3 students have solved 4 problems.        I wish you all can pass the exam!         Come on!       
              

Input

Input contains multiple test cases. Each test case contains an integer N (1<=N<=100, the number of students) in a line first, and then N lines follow. Each line contains P (0<=P<=5 number of problems that have been solved) and T(consumed time). You can assume that all data are different when 0<p.        A test case starting with a negative integer terminates the input and this test case should not to be processed.       
              

Output

Output the scores of N students in N lines for each case, and there is a blank line after each case.       
              

Sample Input

4
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
5 06:30:17
-1
              

Sample Output

100 90 90 95
 
100

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; int M(int i,char T[1005][10])
{
int n;
n=(T[i][2]-'0')*36000+(T[i][3]-'0')*3600+(T[i][5]-'0')*600+(T[i][6]-'0')*60+(T[i][8]-'0')*10+(T[i][9]-'0');
return n;
} int main()
{
//freopen("1.txt","r",stdin);
//freopen("2.txt","w",stdout);
char T[1005][10]={0};
long long score[6][1005]={0};
int c;
while(cin>>c&&c!=-1)
{
getchar();
int j=0;
int a0=0,a1=0,a2=0,a3=0,a4=0;
for(int i=0;i<c;i++){
for(int m=0;m<10;m++)
cin.get(T[i][m]);
getchar();
}
for(int i=0;i<c;i++)
{
if(T[i][0]=='4')
{
score[4][a4++]=M(i,T);
}
if(T[i][0]=='3')
{
score[3][a3++]=M(i,T);
}
if(T[i][0]=='2')
{
score[2][a2++]=M(i,T);
}
if(T[i][0]=='1')
{
score[1][a1++]=M(i,T);
}
}
sort(score[1],score[1]+a1);
sort(score[2],score[2]+a2);
sort(score[3],score[3]+a3);
sort(score[4],score[4]+a4);
for(int i=0;i<c;i++)
{
if(T[i][0]=='4')
{
if(a4==1) {cout<<"95"<<endl; continue;}
for(int k=0;k<a4;k++)
{
if(score[4][k]==M(i,T))
{
if(k<a4/2) {cout<<"95"<<endl; break;}
else {cout<<"90"<<endl; break;}
}
}
}
if(T[i][0]=='3')
{
if(a3==1) {cout<<"85"<<endl; continue;}
for(int k=0;k<a3;k++)
{
if(score[3][k]==M(i,T))
{
if(k<a3/2) {cout<<"85"<<endl; break;}
else {cout<<"80"<<endl; break;}
}
}
}
if(T[i][0]=='2')
{
if(a2==1) {cout<<"75"<<endl; continue;}
for(int k=0;k<a2;k++)
{
if(score[2][k]==M(i,T))
{
if(k<a2/2) {cout<<"75"<<endl; break;}
else {cout<<"70"<<endl; break;}
}
}
}
if(T[i][0]=='1')
{
if(a1==1) {cout<<"65"<<endl; continue;}
for(int k=0;k<a1;k++)
{
if(score[1][k]==M(i,T))
{
if(k<a1/2) {cout<<"65"<<endl; break;}
else {cout<<"60"<<endl; break;}
}
}
}
if(T[i][0]=='5')
{
cout<<"100"<<endl; continue;
}
if(T[i][0]=='0')
{
cout<<"50"<<endl; continue;
}
}
cout<<endl;
}
return 0;
}
 
 
 

HDU 1084 - ACM的更多相关文章

  1. hdu 1084 What Is Your Grade?

    http://acm.hdu.edu.cn/showproblem.php?pid=1084 What Is Your Grade? Time Limit: 2000/1000 MS (Java/Ot ...

  2. HDU 1084 What Is Your Grade?(排序)

    题目在这里:1084 题目描述: “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and yo ...

  3. HDU - 5096 ACM Rank (Treap)

    平衡树的题,Treap破之,比较难搞的出现相同题数罚时的情况,解决方法是在每个结点用一个set, 保证结点值的时候可以把题数和罚时保存到一个int里,令v = n*MaxPenaltySum-pena ...

  4. hdu 5876 ACM/ICPC Dalian Online 1009 Sparse Graph

    题目链接 分析:这叫补图上的BFS,萌新第一次遇到= =.方法很简单,看了别人的代码后,自己也学会了.方法就是开两个集合,一个A表示在下一次bfs中能够到达的点,另一个B就是下一次bfs中到不了的点. ...

  5. hdu 5875 ACM/ICPC Dalian Online 1008 Function

    题目链接 分析:用RMQ预处理每段的最小值,然后对每次查询的区间找最靠近左边的小于的值,取模后递归操作.因为每次取模至少会使原来的值减半,所以递归操作是的.每次查询最小值如果通过线段树那么最终的复杂度 ...

  6. HDU contest808 ACM多校第7场 Problem - 1008: Traffic Network in Numazu

    首先嘚瑟一下这场比赛的排名:59 (第一次看到这么多 √ emmmm) 好了进入正文QAQ ...这道题啊,思路很清晰啊. 首先你看到树上路径边权和,然后还带修改,不是显然可以想到 树剖+线段树 维护 ...

  7. HDU 1084:What Is Your Grade?

    Problem Description "Point, point, life of student!" This is a ballad(歌谣)well known in col ...

  8. 杭电(hdu)ACM 1010 Tempter of the Bone

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  9. 杭电(hdu)ACM 4548 美素数

    美素数 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submis ...

随机推荐

  1. 纯js实现div内图片自适应大小

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. 用RBG颜色设置自定义颜色

    这个是Mac自带的测色计   快捷键shift + command + c即可复制RBG格式的颜色 #DD0000 这个是csdn 的logo里的红色 我们得到的是十六位颜色代码 但是UIColor( ...

  3. [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha

    Problem B. Cookie Clicker Alpha   Introduction Cookie Clicker is a Javascript game by Orteil, where ...

  4. Blogger建立新文章 - Blog透视镜

    使用Blogger,建立好Blog部落格之后,接着就是建立新文章,它是Blog部落格的灵魂,先从简单开始,来了解建立新文章的标题,文章中如何上传图片,建立卷标,及设定排程日期,定时自动发布等这些功能, ...

  5. 如何删除textarea的移动版Safari的阴影?

    如何删除textarea的移动版Safari的阴影? 在iphone的Safari上运行网页,textarea无法使用box-shadow样式,而且顶部有内阴影,如何清除? 添加评论 分享   赞同1 ...

  6. Android的init过程详解(一)(转)

    本文使用的软件版本 Android:4.2.2 Linux内核:3.1.10 本文及后续几篇文章将对Android的初始化(init)过程进行详细地.剥丝抽茧式地分析,并且在其中穿插了大量的知识,希望 ...

  7. perl 获取阿里云主机信息

    use LWP::UserAgent; use Data::UUID; use Data::GUID; use HTTP::Date qw(time2iso str2time time2iso tim ...

  8. error C2143 & error C4430

    错误 1 error C2143: 语法错误 : 缺少“;”(在“*”的前面) 错误 2 error C4430: 缺少类型说明符 - 假定为 int.注意: C++ 不支持默认 int 错误 3 e ...

  9. Linux文件系统挂载管理

    http://itercast.com/lecture/19 文件系统创建好之后需要挂载到系统中方可使用,windows.Mac系统会自动挂载文件系统,而Linux下一般需要手工挂载或配置系统进行自动 ...

  10. 《Java程序员面试笔试宝典》之为什么需要public static void main(String[] args)这个方法

    public staticvoid main(String[] args)为Java程序的入口方法,JVM在运行程序的时候,会首先查找main方法.其中,public是权限修饰符,表明任何类或对象都可 ...