What Is Your Grade?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8522 Accepted Submission(s): 2616
Problem 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!
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.
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
Author
lcy
数据处理题最主要的时看清题 细心点就行
注意每个层次只有一个人的时候这个人可以拿到该层次的最高分。。
具体处理下面代码有注释。。。。。。
#include<iostream>
#include<cstdio>
#include<cstring>
#define M 100001000
#include<algorithm>
using namespace std;
struct node{
int n,time;
}a[1005];//记录每个同学的答题状态和所用时间
int main()
{
int cas,flag5,flag4,flag3,flag2,flag1;//用于统计每个层次的人数
int s[1005],sa[1005],e[1005],y[1005];//记录每个层次排名前50%的人的位置
int n,i;
int l,q,p,k;
char str[20];
while(cin>>cas)
{
if(cas<0)
break;
flag4=flag3=flag2=flag1=0;
for(i=0;i<cas;i++)
{
cin>>a[i].n;
if(a[i].n==4)
flag4++;
else if(a[i].n==3)
flag3++;
else if(a[i].n==2)
flag2++;
else if(a[i].n==1)
flag1++;
cin>>str;
a[i].time=3600*(10*(str[0]-'0')+str[1]-'0')+60*(10*(str[3]-'0')+str[4]-'0')+10*(str[6]-'0')+str[7]-'0';//全部转化为秒
}
if(flag4!=1)
flag4=(flag4)/2;
if(flag3!=1)
flag3=flag3/2;
if(flag2!=1)
flag2=flag2/2;
if(flag1!=1)
flag1=flag1/2;
//每个层次只有前一半能拿到该层次的最高分 当每个层次只有一个人的时候那么这个人就能拿到该层次的最高分
l=0;q=0;p=0;k=0;
int b;
int mixn;
for(i=0;i<cas;i++) //标记出每个层次排名前50%的人的位置
{
if(a[i].n==4&&flag4)
{
mixn=a[i].time;
b=i;
for(int j=0;j<cas;j++)//每次循环都能找出该层次中用时最少的那个人的位置
//并将其标记且赋一个很大的值保证下次循环不会再被使用
{
if(a[j].n==4&&a[j].time<mixn)
{
mixn=a[j].time;
b=j;
}
}
s[l++]=b;
a[b].time=M;
flag4--;
}
if(a[i].n==3&&flag3)
{
mixn=a[i].time;
b=i;
for(int j=0;j<cas;j++)
{
if(a[j].n==3&&a[j].time<mixn)
{
mixn=a[j].time;
b=j;
}
}
sa[q++]=b;
a[b].time=M;
flag3--;
}
if(a[i].n==2&&flag2)
{
mixn=a[i].time;
b=i;
for(int j=0;j<cas;j++)
{
if(a[j].n==2&&a[j].time<mixn)
{
mixn=a[j].time;
b=j;
}
}
e[p++]=b;
a[b].time=M;
flag2--;
}
if(a[i].n==1&&flag1)
{
mixn=a[i].time;
b=i;
for(int j=0;j<cas;j++)
{
if(a[j].n==1&&a[j].time<mixn)
{
mixn=a[j].time;
b=j;
}
}
y[k++]=b;
a[b].time=M;
flag1--;
}
}
for(i=0;i<cas;i++)//输出
{
if(a[i].n==5)
cout<<"100"<<endl;
else if(a[i].n==4)
{
flag4=0;//前面的flag在后面没有用了所以偷了点懒重新利用了一下用于标记该同学的排名是否是他所处层次的前50%
for(int j=0;j<l;j++)
{
if(s[j]==i)
{
cout<<"95"<<endl;
flag4=1;
break;
}
}
if(!flag4)
{
cout<<"90"<<endl;
}
}
else if(a[i].n==3)
{
flag3=0;
for(int j=0;j<q;j++)
{
if(sa[j]==i)
{
cout<<"85"<<endl;
flag3=1;
break;
}
}
if(!flag3)
{
cout<<"80"<<endl;
}
}
else if(a[i].n==2)
{
flag2=0;
for(int j=0;j<p;j++)
{
if(e[j]==i)
{
cout<<"75"<<endl;
flag2=1;
break;
}
}
if(!flag2)
{
cout<<"70"<<endl;
}
}
else if(a[i].n==1)
{
flag3=0;
for(int j=0;j<k;j++)
{
if(y[j]==i)
{
cout<<"65"<<endl;
flag3=1;
break;
}
}
if(!flag3)
{
cout<<"60"<<endl;
}
}
else
cout<<"50"<<endl;
}
cout<<endl;
}
return 0;
}