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 sysu_wwl at 2008-11-18 20:47:34 on Problem 1260
#include<stdio.h>
#include<algorithm>
using namespace std;
struct pri
{
	__int64 num;
	__int64 price;
};
int main()
{
	__int64 t,c,i,j;
	pri a[110];
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&c);
		for(i=0;i<c;i++)
			scanf("%lld %lld",&a[i].num,&a[i].price);
		if(c==1)
		{
			printf("%lld\n",(a[0].num+10)*a[0].price);
			continue;
		}
		for(i=1;i<c;i++)
			for(j=0;j<i;j++)
				if(a[j].num!=0)
					if((a[j].num+10)*a[j].price>=a[j].num*a[i].price)
					{
						a[i].num+=a[j].num;
						a[j].num=0;
					}
		__int64 sum=0;
		for(i=0;i<c;i++)
			if(a[i].num!=0)
				sum+=(a[i].num+10)*a[i].price;
		printf("%lld\n",sum);
	}
}

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