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

此题的DP解法

Posted by qqwqert007 at 2011-05-03 22:33:24 on Problem 1018
  起初看到网上将此题归类为DP,所以就来做了,开始的思路是用dp[i][j]记录选用第i组设备,费用为j时的最大带宽,类似分组背包。后来提交WA,发现,费用的上限很大,数组开不了那么大。
  然后在discuss里发现有的童鞋说带宽的上限不大,于是就用dp[i][j]记录选用第i组设备,带宽为j时的最小费用。对每一个设备,状态转移方程
for (i=1;i<=n;i++)
   for (j=0;j<MAX;j++)
       f[i][min(j,a)]=min(f[i][min(j,a)],f[i-1][j]+b);
其中a为其带宽,b为其费用。
最后,只需要在f[n][j]中找出j/f[n][j]的最大值即可。
				

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