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

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

/状态: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. hdu 2191多重背包

    悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  2. CCFileUtils::getFileData疑惑

    背景 这几天在使用cocos2d-x读取磁盘文件的时候,发现了CCFileUtils中一点不合理的地方,特此记录,以供研讨. 项目结构 ①我使用的是cocos2d-x 2.1.3版本,CCFileUt ...

  3. mysql索引之组合索引

    多列索引又称组合索引,在mysql的查询操作中,我们经常会遇到多个搜索条件,如:$sql = "select * from article where content='ma4' and t ...

  4. JQuery实现倒计时效果

    首先:引入jquery文件 <script type="text/javascript" src="http://www.cnblogs.com/Content/P ...

  5. AngularJS实现表单手动验证和表单自动验证

    AngularJS的表单验证大致有两种,一种是手动验证,一种是自动验证.一.手动验证 所谓手动验证是通过AngularJS表单的属性来验证.而成为AngularJS表单必须满足两个条件: 1.给for ...

  6. Shell脚本调试技术

    http://www.ibm.com/developerworks/cn/linux/l-cn-shell-debug/ 一. 前言 shell编程在unix/linux世界中使用得非常广泛,熟练掌握 ...

  7. Netbeans使用Xdebug调试的配置

    在phpinfo()信息里找到php.ini的位置并打开php.ini在文档最后添加如下代码: 注释原来xdebug配置 xdebug.remote_enable=onxdebug.remote_ha ...

  8. Google谷歌推出goo.gl缩短网址服务 - Blog透视镜

    Blog部落格文章的网址,例如本篇文章:http://blog.openyu.org/2014/01/google-goo.gl.html,通常都很冗长,分享到社群网站上,容易使得讯息内容过多,同时也 ...

  9. oracle安装报错2

    [oracle@centos1 database]$ ./runInstaller Starting Oracle Universal Installer... Checking installer ...

  10. ExpandableListView 保证只展开一组

    expandableListView.setOnGroupExpandListener(new OnGroupExpandListener(){ @Override public void onGro ...