Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

很简单的一道题,只要读懂题目,其他不是问题

Posted by wzp_moon at 2015-09-28 13:54:18 on Problem 1581
/***********************************************************************
    Copyright (c) 2015,wangzp
    All rights no reserved.
  
    Name: 《A Contesting Decision》In PEKING UNIVERSITY ACM
    ID:   PROBLEM 1581
    问题简述: 求几个参赛队伍中罚分最少的队伍,规则如下:
	          1.提交1次通过时间即为罚的分数;
	          2.提交问题没有通过,不管次数为多少次,罚分为0;
	          3.提交问题通过,但是大于等于2次,没多一次,就多罚20分;
	          4.先看答对题目最多,然后再看总罚分数最少的队伍即为胜利者。
    Date: Sep 28, 2015 
 
***********************************************************************/
#include<stdio.h>
#include <string.h>

#define MAX_SCORE 10000000
#define CONTESTER 100
typedef struct {
	char name[20];
	int test_num[4];
	int test_time[4];
	int num_sloved;
	int sum_score;

}CONTEST;

/*根据规则,计算罚分*/
int contest_fun(int num,int time)
{
	int sum = 0;
	if (num == 1 && time != 0)
	{
		sum += time;
	} 
	else if (num > 1 && time != 0)
	{
		sum = time;
		while (num > 1)
		{
			sum += 20;
			num--;
		}
	}
	return sum;
}

int main(void)
{
	CONTEST contest_sub[CONTESTER];
	int min_score,index,sloved;
	int i,j,n;
	memset(contest_sub,NULL,CONTESTER*sizeof(CONTEST));

	min_score = MAX_SCORE;
	index = 0;
	sloved = -1;

	scanf("%d",&n);
	for (i = 0;i < n;i++)
	{
		scanf("%s",contest_sub[i].name);
		for (j = 0;j < 4;j++)
		{
			scanf("%d",&contest_sub[i].test_num[j]);
			scanf("%d",&contest_sub[i].test_time[j]);
			if (contest_sub[i].test_time[j] != 0)
			{
				contest_sub[i].num_sloved++;
			}
			contest_sub[i].sum_score += contest_fun(contest_sub[i].test_num[j],contest_sub[i].test_time[j]);
		}
		
		if (contest_sub[i].num_sloved >= sloved)
		{
			if (contest_sub[i].sum_score <= min_score)
			{
				sloved = contest_sub[i].num_sloved;
				min_score = contest_sub[i].sum_score;
				index = i;
			}
		}
	}
	printf("%s %d %d\n",contest_sub[index].name,contest_sub[index].num_sloved,contest_sub[index].sum_score);	
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator