摘要:
Chopsticks题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=234题目大意:给定n个筷子的长度,取k+8套筷子,每套有3个,长度分别为A,B,C。要求k+8套筷子中(A-B)^2的和最小,输出这个最小值。分析:题目中筷子长度是非降序排列的,所以最小的两个A和B一定是相邻的。先不考虑筷子C,只要留着就行。 令dp[i][j]表示从 j 个筷子中取 i 套筷子的最优值。 dp[i][j] = min {dp[i][j-1] , dp[i-1][j-1] | (n - j > 3*(k - i))剩下的筷子 阅读全文
posted @ 2013-08-15 02:56
贾树丙
阅读(666)
评论(0)
推荐(0)
摘要:
Common SubsequenceTime Limit:2 Seconds Memory Limit:65536 KBA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a strictly increasing sequence of indices of X such that... 阅读全文
posted @ 2013-08-15 02:40
贾树丙
阅读(327)
评论(0)
推荐(0)

浙公网安备 33010602011771号