poj1581

A Contesting Decision
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 2519   Accepted: 1786

Description

Judging a programming contest is hard work, with demanding contestants, tedious decisions,and monotonous work. Not to mention the nutritional problems of spending 12 hours with only donuts, pizza, and soda for food. Still, it can be a lot of fun.
Software that automates the judging process is a great help, but the notorious unreliability of some contest software makes people wish that something better were available. You are part of a group trying to develop better, open source, contest management software, based on the principle of modular design.
Your component is to be used for calculating the scores of programming contest teams and determining a winner. You will be given the results from several teams and must determine the winner.
Scoring
There are two components to a team's score. The first is the number of problems solved. The second is penalty points, which reflects the amount of time and incorrect submissions made before the problem is solved. For each problem solved correctly, penalty points are charged equal to the time at which the problem was solved plus 20 minutes for each incorrect submission. No penalty points are added for problems that are never solved.
So if a team solved problem one on their second submission at twenty minutes, they are charged 40 penalty points. If they submit problem 2 three times, but do not solve it, they are charged no penalty points. If they submit problem 3 once and solve it at 120 minutes, they are charged 120 penalty points. Their total score is two problems solved with 160 penalty points.
The winner is the team that solves the most problems. If teams tie for solving the most problems,then the winner is the team with the fewest penalty points.

Input

For the programming contest your program is judging, there are four problems. You are guaranteed that the input will not result in a tie between teams after counting penalty points.
Line 1 < nTeams >
Line 2 - n+1 < Name > < p1Sub > < p1Time > < p2Sub > < p2Time > ... < p4Time >
The first element on the line is the team name, which contains no whitespace.Following that, for each of the four problems, is the number of times the team submitted a run for that problem and the time at which it was solved correctly (both integers). If a team did not solve a problem, the time will be zero. The number of submissions will be at least one if the problem was solved.

Output

The output consists of a single line listing the name of the team that won, the number of problems they solved, and their penalty points.

Sample Input

4
Stars 2 20 5 0 4 190 3 220
Rockets 5 180 1 0 2 0 3 100
Penguins 1 15 3 120 1 300 4 0
Marsupials 9 0 3 100 2 220 3 80

Sample Output

Penguins 3 475

Source

 
 1 #include <iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 using namespace std;
 5 const int penaliy = 20;
 6 
 7 int main()
 8 {
 9     int n;
10     while(scanf("%d",&n)!=EOF)
11     {
12         char str[20];
13         int a[4],b[4];
14         int maxsolved = -9999;
15         int mintime = 32766;
16         char winner[20];
17         for(int i=0;i<n;i++)
18         {
19             scanf("%s%d%d%d%d%d%d%d%d",str,&a[0],&b[0],&a[1],&b[1],&a[2],&b[2],&a[3],&b[3]);
20             int solved = 0;
21             int time = 0;
22             for(int j=0;j<4;j++)
23             {
24                 if(b[j]!=0)
25                 {
26                     solved++;
27                     time+=b[j]+(a[j]-1)*penaliy;
28                 }
29             }
30             if(maxsolved<solved)
31             {
32                 strcpy(winner,str);
33                 maxsolved = solved;
34                 mintime = time ;
35             }
36             else if(maxsolved==solved)
37             {
38                 if(mintime>time)
39                 {
40                     mintime=time;
41                     strcpy(winner,str);
42                     maxsolved = solved;
43                 }
44             }
45         }
46         cout<<winner<<" "<<maxsolved<<" "<<mintime<<endl;
47     }
48     return 0;
49 }

 

posted @ 2014-08-14 10:08  Fighting_frank  阅读(130)  评论(0编辑  收藏  举报