What Is Your Grade?(1084)

“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 <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
typedef struct 
{
	int num;
	int h;
	int f;
	int s;	
	int rank;
	int score;
}student;

int comp(student *a,student *b)
{
	if(a->h<b->h)
	return 1;
	else if(a->h>b->h)
	return -1;
	else
	{
		if(a->f<b->f)
		return 1;
		else if(a->f>b->f)
		return -1;
		else 
		{
			if(a->s<b->s)
			return 1;
			else if(a->s>b->s)
			return -1;
		}
	}	
}

void deal(student *stu,int shu,int n,int num)
{
	int time,i,location,count;
	student t,*p;
	time=shu;
	count=1;
	while(time--)
	{	
		p=stu;
		t.h=25;
		t.f=61;
		t.s=61;
		for(i=0;i<n;i++)
		{
		
			if(p->num==num && p->rank==0)
			{
				if(comp(p,&t)>0)
				{
					t.h=p->h;
					t.f=p->f;
					t.s=p->s;
					location=i;
				}
			}
			p++;
		}
		p=stu;
		p+=location;
		p->rank=count;
		count++;		
	}	
}
int main()  
{	
	student stu[100];
	int i,n;
	int yi,er,san,si;
	while(scanf("%d",&n)!=EOF)
	{
		if(n<0)
		break;
		yi=er=san=si=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&stu[i].num);
			scanf("%d:%d:%d",&stu[i].h,&stu[i].f,&stu[i].s);
			stu[i].rank=0;
			if(stu[i].num==5)
			stu[i].score=100;
			else if(stu[i].num==0)
			stu[i].score=50;
			else if(stu[i].num==1)
			yi++;
			else if(stu[i].num==2)
			er++;
			else if(stu[i].num==3)
			san++;
			else if(stu[i].num==4)
			si++;
		}		
		
		deal(stu,si,n,4);
		deal(stu,san,n,3);
		deal(stu,er,n,2);
		deal(stu,yi,n,1);
		
		for(i=0;i<n;i++)
		{
			if(stu[i].num==5)
			printf("100\n");
			else if(stu[i].num==0)
			printf("50\n");
			else if(stu[i].num==4 && stu[i].rank<=(si/2))
			printf("95\n");
			else if(stu[i].num==4)
			printf("90\n");
			else if(stu[i].num==3 && stu[i].rank<=(san/2))
			printf("85\n");
			else if(stu[i].num==3)
			printf("80\n");
			else if(stu[i].num==2 && stu[i].rank<=(er/2))
			printf("75\n");
			else if(stu[i].num==2)
			printf("70\n");
			else if(stu[i].num==1 && stu[i].rank<=(yi/2))
			printf("65\n");
			else if(stu[i].num==1)
			printf("60\n");
		}
		printf("\n");		
	}
	
    return 0;  
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章