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

做了一天,终于在pku上做出了一道!发狂中!DP o (n) 附个人思路

Posted by lyl625760 at 2009-04-05 18:11:36 on Problem 2181 and last updated at 2009-04-05 18:14:03
a[i] : input data
b[i] : 前i 个 元素的且经历奇数步的最高值
c【i】:前i 个 元素的且经历偶数步的最高值
则 根据b【i】   c【i】  有没有用到a【i】分类即可
  
b[i]=max(b[i-1],c[i-1]+a[i])
c[i]=max(c[i-1],b[i-1]-a[i])


可用两个变量代替b【i】c【i】。显然结果就是b【n】
菜鸟只能想这么多了,希望大家多多发言,要不然偶这么多题不会做怎么办啊



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