Red Huang

Red Huang

uva 709

dp [i] 表示某行到第 i 個單字結束的時候最小的 badness

dp[i] = min{dp[i-1]+500,dp[j]+badness

(參考至http://www.cnblogs.com/staginner/archive/2011/12/07/2279059.html)

所以 dp [i] 當作是下一行的一個字

也可以當作接在別的字後面

如果當做下一行開始,則 dp [i-1] 就是上一行 + 500

接在別的字後面的話,dp [i+1] 到 dp [j] 組成一行

也就是

this___________ <=dp[1] 500
this__________is <=dp[2]
this___is____best <=dp[3]

然後再用 dp [2] 跟 dp [1] 做比對

this___________
is____________ dp[2]

this___________
is_____best____ dp[3]

this___________
is____________
best___________ dp[3]

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。