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 hplonline at 2008-07-12 14:10:50 on Problem 1260 and last updated at 2008-07-12 14:12:33
每次都看相临的两个,如果把当前这一批放入下一个等级价格降低,
则将他放到下一个等级,否则直接算在当前等级的买的价格加到答案中,
最后一等后设置最大值,保证不会再向后放.

		a[n]=100000;p[n]=100000;
		ans=0;
		for (i=0;i<n;i++){
			if ((a[i]+10)*p[i]>a[i]*p[i+1])
				a[i+1]+=a[i];
			else ans+=(a[i]+10)*p[i];
		}



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