A Contesting Decision

本文介绍了一个用于自动评估程序设计竞赛的评分系统实现方法。通过解析输入数据,计算各队解决问题的数量及罚时,最终确定获胜队伍。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



题目描述

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.

输入

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.

输出

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.

样例输入

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

样例输出

Penguins 3 475

提示

对程序设计竞赛进行裁判是一项艰苦的工作,要面对要求严格的参赛选手,作出乏味的决定,以及进行着单调的工作。不过,这其中也可以有很多乐趣。
对于程序设计竞赛的裁判来说,用软件使得评测过程自动化很有帮助。你是致力于将竞赛管理软件开发得更好的团队中的一员。基于模块化设计原则,你所开发的模块的功能是为参加程序设计竞赛的队伍计算分数并确定优胜者。给出参赛队伍在比赛中的情况,请确定比赛的优胜者。
记分规则:
一支参赛队的记分由两部分组成:第一部分是被解出的题数,第二部分是罚时,表示解题总的耗费时间和试题没有被解出前错误的提交所另加的罚时。对于每个被正确解出的问题,罚时等于该问题被解出的时间加上每次错误提交的20分钟罚时。在问题没有被解出前不加罚时。
因此,如果一支队伍在比赛20分钟的时候在第二次提交解出第1题,他们的罚时是40分钟。如果他们提交第2题3次,但没有解决这个问题,则没有罚时。如果他们在120分钟提交第3题,并一次解出的话,该题的罚时是120分钟。这样,该队的成绩是罚时160分钟,解决两个问题。
优胜队是解出最多问题的队。如果两队在解题数上打成平手,那么罚时少的队是优胜队。
输入
程序评判的程序设计竞赛有4题。程序要确保在计算罚时后,不会导致队与队之间不分胜负的情况。
第1行为参赛队数n;
第2~n+1行为每个队的参赛情况。每行的格式为:< Name > < p1Sub > < p1Time > < p2Sub > < p2Time > … < p4Time >
第一个元素是不含空格的队名。后面是对于4道试题的解题情况(该队对这一试题的提交次数和正确解出该题的时间(都是整数))。如果没有解出该题,则解题时间为0。如果一道试题被解出,提交次数至少是一次。
输出
输出一行。给出优胜队的队名、解出题目的数量以及罚时。

题解:

#include <iostream>  
#include <cstring>
#include <string>
//#include <climits>//INT_MAX在此中定义
using namespace std;
int main()
{
	    int n;
	    int submit, time, firstsub, firsttime, number, use_time, t;
	    string team, firstteam;
	    cin >> n;
	    firstsub = 0;
		firsttime = 0;//可视具体情况而定// firsttime = INT_MAX;
	    while (n--)
		    {
		        cin >> team;
		        use_time = t = 0;
		        for (number = 0; number<4; number++)
			        {
			            cin >> submit >> time;
			           if (time>0)
				           {
				                use_time += time + 20*(submit - 1);
				                t++;
				            }
			        }
		          // cout<<team<<" "<<k<<" "<<j<<endl;
			
			        if ((t>firstsub) || (t == firstsub && use_time<firsttime))//解题数量多||解题数量一致但用时少
			        {
			            firstteam = team;
			            firstsub = t;
			            firsttime = use_time;
			        }
		   }
	   cout<<firstteam<<" "<<firstsub<< " " << firsttime << endl;
	    return 0;
	}

欢迎交流!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值