HDU 1084 - ACM

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

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

/状态: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;
}

时间: 2024-11-05 14:59:41

HDU 1084 - ACM的相关文章

HDU 1084 [What Is Your Grade?] 结构体排序

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1084 题目大意:共5道题,N个学生.做出5道满分,0道50分.做出1-4道的同学,若在前50%(向下取整),则获得95.85.75.65,若在后50%则获得90.80.70.60. 关键思想:结构体排序 //结构体排序,考虑边界 #include <iostream> #include <algorithm> #include <cmath> #include <me

HDU 1084 - What Is Your Grade?

给出第 i 个学生做完的题数和时间,给学生打分 排个序就行了吧 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 using namespace std; 6 const int N=105; 7 struct stu{ 8 int h,m,s,num,sco; 9 }a[10][N]; 10 int n,m[N],p,h,mm,s,

杭电 HDU ACM Coder (STL)

欢迎参加--每周六晚的BestCoder(有米!) Coder Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4200    Accepted Submission(s): 1630 Problem Description In mathematics and computer science, an algorithm desc

杭电(hdu)ACM 4548 美素数

美素数 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 4482    Accepted Submission(s): 1524 Problem Description 小明对数的研究比較热爱,一谈到数.脑子里就涌现出好多数的问题,今天.小明想考考你对素数的认识. 问题是这种:一个十进制数.假设是素数,并且它的各位数字和也是素数,则称之

杭电(hdu)ACM 1231 最大连续子序列

最大连续子序列 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23078    Accepted Submission(s): 10282 Problem Description 给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 <= i <= j

HDU - 5096 ACM Rank (Treap)

平衡树的题,Treap破之,比较难搞的出现相同题数罚时的情况,解决方法是在每个结点用一个set,比较值的时候可以把题数和罚时保存到一起. 初始化有一定技巧.细节很多容易出错. 写错一个变量名字查好久,尴尬 #include<cstdio> #include<iostream> #include<string> #include<cstring> #include<queue> #include<vector> #include<

杭电(hdu)ACM 1003 Max Sum

Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 178139    Accepted Submission(s): 41558 Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max s

杭电 HDU ACM Strange fuction

Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4124    Accepted Submission(s): 2964 Problem Description Now, here is a fuction: F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=

杭电 HDU ACM 1028 Ignatius and the Princess III

Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14870    Accepted Submission(s): 10469 Problem Description "Well, it seems the first problem is too easy. I will le