There is a row of n coins whose values are some positive integers c₁, c₂,...,cn, not necessarily distinct. The goal is to pick up the maximum amount of money subject to the constraint that no two coins adjacent in the initial row can be picked up.
输入
Two lines, the first line is n (0< n <=10000), and the second line is value of coin(0< value <= 2^32).
输出
the maximum amount of money.
样例输入
6 5 1 2 10 6 2
样例输出
17
分析:
首先问题的意思是,在原始位置互不相邻的条件下,所选硬币的总值最大。设第 i 个硬币币值为 Ci,可选最大金额为 F(i)。
SWUST OJ 之 1139 Coin-row problem
最新推荐文章于 2024-12-10 20:38:06 发布