码迷,mamicode.com
首页 > 其他好文 > 详细

2015-基础(7)

时间:2015-02-04 14:48:20      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:acm   c   c++   

I - I

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>
using namespace std;
int main ()
{
	int n,i,j;
	char b[110];
	while(cin >> n)
	{
		long long a[110]={0},c[110]={0},e[110]={0};
		int q[5]={0};
		if(n==-1)
		{
			break;
		}
		for(i=0;i<n;++i)
		{
			cin >> c[i];
			if(c[i]==4)
			{
				q[4]++;
			}
			if(c[i]==3)
			{
				q[3]++;
			}
			if(c[i]==2)
			{
				q[2]++;
			}
			if(c[i]==1)
			{
				q[1]++;
			}
			cin >> b;
			for(j=0;b[j]!='\0';++j)
			{
				if(b[j]!=':')
				{
					a[i]+=b[j]-'0';
				}
				a[i]*=10;
			}
		}
		q[4]/=2;
		q[3]/=2;
		q[2]/=2;
		q[1]/=2;
		for(i=0;i<n;++i)
		{
			for(j=0;j<n;++j)
			{
				if(c[i]==4)
				{
					if(a[i]>a[j]&&c[j]==4)
				  {
					  e[i]++;
				  }
				}
			    else if(c[i]==3)
				{
					if(a[i]>a[j]&&c[j]==3)
				  {
					  e[i]++;
				  }
				}
				 else if(c[i]==2)
				{
					if(a[i]>a[j]&&c[j]==2)
				  {
					  e[i]++;
				  }
				}
				 else if(c[i]==1)
				{
					if(a[i]>a[j]&&c[j]==1)
				  {
					  e[i]++;
				  }
				}
			}
		}
	/*	for(i=0;i<n;i++)
		{
			cout << e[i]+1 << endl;
		}*/
		for(i=0;i<n;i++)
		{
			if(c[i]==5)
			{
				cout << 100 << endl;
			}
			else if(c[i]==0)
			{
				cout << 50  << endl;
			}
			else if(c[i]==4)
			{
				if(e[i]+1>q[4])
				  {
					  cout << 90  << endl;
				  }
				else
				{
					cout << 95  << endl;
				}
			}
			else if(c[i]==3)
			{
				 if(e[i]+1>q[3])
				  {
					  cout << 80 << endl;
				  }
				else
				{
					cout << 85 << endl;
				}
			}
			else if(c[i]==2)
			{
				 if(e[i]+1>q[2])
				  {
					  cout << 70 << endl;
				  }
				else
				{
					cout << 75  << endl;
				}
			}
			else if(c[i]==1)
			{
				 if(e[i]+1>q[1])
				  {
					  cout << 60 << endl;
				  }
				else
				{
					cout << 65 << endl;
				}
			}
		}
		cout << endl;
	}
	return 0;
}


2015-基础(7)

标签:acm   c   c++   

原文地址:http://blog.csdn.net/zsc2014030403015/article/details/43484575

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!