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

我是假设bi的值是一定属于A序列的,灵感来自于曾经做过的一题使A有序的最小代价,那么可以有dp[i][j]代表第i个数取Aj的最小值,O(N3)AC了

Posted by yygy at 2012-11-15 13:31:43 on Problem 2313
In Reply To:Re:DP的话貌似很容易超时阿。 Posted by:gzw_02 at 2008-07-26 21:44:34
> 正确性尚且不考虑,如果不加优化用DP, 
> 用V[i,j]表示取B(i)=j的时候V的最优值。  
> V[i,j]= min(V[i-1,k]+abs(j-k)+abs(A(i)-j))(-10000<=k<=10000)
> 这样, 
> 100×10000×10000×4
> 超时是很容易的。
> 
> 不知怎样优化呢?

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