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

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

/状态: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. c#串口编程时,忽略跨线程检查报错

    1.直接在main_Form_Load的初始化中加 //忽略跨线程检查 // System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls ...

  2. Lua 字符串 匹配模式 总结

    字符类 %a --字母alpha %d --数字double %l --小写字母lower %u --大写字母upper %w --字母和数字word %x -- 十六进制 %z --代表0 zero ...

  3. 一个商品练习的py

    #!/usr/bin/env python # coding=utf-8 # by 星空刺 qian = int(raw_input("请输入当前money:")) gongzi ...

  4. JQuery基础学习总结

    JQuery基础学习总结 简单总结下JQuery: 一:事件 1.change事件 <!DOCTYPE html> <html lang="en"> < ...

  5. Linux_Shell type

    Recommendation is to use the bash shell, because he is strong enough, and absorbed the useful proper ...

  6. 配置wamp环境使得在命令行下也能执行socket扩展

    首先在apache中开启socket扩展 php环境安装目录\bin\apache\apache2.2.17\bin\php.ini 去掉前面的';'   extension=php_sockets. ...

  7. Light OJ 1095 Arrange the Numbers(容斥)

    给定n,m,k,要求在n的全排列中,前m个数字中恰好有k个位置不变,有几种方案?首先,前m个中k个不变,那就是C(m,k),然后利用容斥原理可得 ans=ΣC(m,k)*(-1)^i*C(m-k,i) ...

  8. LeetCode_Word Ladder

    Given two words (start and end), and a dictionary, find the length of shortest transformation sequen ...

  9. Linux配置完iptables后,重启失效的解决方案

    Linux配置完iptables后,重启失效的解决方案 因为只有root用户才可访问1024以下的端口,非root用户登陆是不能启用80端口的.web service 往往启动1024以上的端口,并通 ...

  10. C/C++ 指针的非空判断

    一定要分得清楚C和C++的“空指针常量”不是一样的.C标准不保证NULL等于0,所以做指针非空判断时,应该用if(p != NULL):因为“上下文转换到bool值”的统一性,C++就应该用if(p) ...