BZOJ 2101: [Usaco2010 Dec]Treasure Chest 藏宝箱( dp )
dp( l , r ) = sum( l , r ) - min( dp( l + 1 , r ) , dp( l , r - 1 ) )
被卡空间....我们可以发现 l > r 是无意义的 , 所以可以省下一半的空间
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
2101: [Usaco2010 Dec]Treasure Chest 藏宝箱
Time Limit: 10 Sec Memory Limit: 64 MB
Submit: 374 Solved: 174
[Submit][Status][Discuss]
Description
Bessie and Bonnie have found a treasure chest full of marvelous gold coins! Being cows, though, they can't just walk into a store and buy stuff, so instead they decide to have some fun with the coins. The N (1 <= N <= 5,000) coins, each with some value C_i (1 <= C_i <= 5,000) are placed in a straight line. Bessie and Bonnie take turns, and for each cow's turn, she takes exactly one coin off of either the left end or the right end of the line. The game ends when there are no coins left. Bessie and Bonnie are each trying to get as much wealth as possible for themselves. Bessie goes first. Help her figure out the maximum value she can win, assuming that both cows play optimally. Consider a game in which four coins are lined up with these values: 30 25 10 35 Consider this game sequence: Bessie Bonnie New Coin Player Side CoinValue Total Total Line Bessie Right 35 35 0 30 25 10 Bonnie Left 30 35 30 25 10 Bessie Left 25 60 30 10 Bonnie Right 10 60 40 -- This is the best game Bessie can play.
Input
* Line 1: A single integer: N * Lines 2..N+1: Line i+1 contains a single integer: C_i
Output
* Line 1: A single integer, which is the greatest total value Bessie can win if both cows play optimally.
Sample Input
30
25
10
35
Sample Output
HINT
(贝西最好的取法是先取35,然后邦妮会取30,贝西再取25,邦妮最后取10)
Source
Silver
转载于:https://www.cnblogs.com/JSZX11556/p/4592378.html
BZOJ 2101: [Usaco2010 Dec]Treasure Chest 藏宝箱( dp )相关推荐
- bzoj2101【Usaco2010 Dec】Treasure Chest 藏宝箱
2101: [Usaco2010 Dec]Treasure Chest 藏宝箱 Time Limit: 10 Sec Memory Limit: 64 MB Submit: 418 Solved: ...
- BZOJ 2097 [Usaco2010 Dec]Exercise 奶牛健美操
[题意] 给出一棵树.现在可以在树中删去m条边,使它变成m+1棵树.要求最小化树的直径的最大值. [题解] 二分答案.$Check$的时候用$DP$,记录当前节点每个儿子的直径$v[i]$,如果$v[ ...
- Uva12325 Zombie's Treasure Chest [二分区间+模拟退火]
Zombie's Treasure Chest 题目链接 https://cn.vjudge.net/problem/UVA-12325 题意 两种物品无穷多个,第一种物品重量s1s_1s1,价值v ...
- UVA 12325 宝箱 Zombie‘s Treasure Chest
宝箱 Zombie's Treasure Chest 题面翻译 你有一个体积为N的箱子和两种数量无限的宝物.宝物1的体积为S1,价值为V1::宝物2的体积为S2,价值为V2.输入均为32位带符号整数. ...
- BZOJ 1827: [Usaco2010 Mar]gather 奶牛大集会 树形DP
[Usaco2010 Mar]gather 奶牛大集会 Bessie正在计划一年一度的奶牛大集会,来自全国各地的奶牛将来参加这一次集会.当然,她会选择最方便的地点来举办这次集会.每个奶牛居住在 N(1 ...
- bzoj 1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚(DP)
1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 941 Solved ...
- [DP/单调队列]BZOJ 2059 [Usaco2010 Nov]Buying Feed 购买饲料
首先我想吐槽的是题目并没有表明数据范围... 这个题目 DP方程并不难表示. dp[i][j]表示前i个地点携带了j个货物的最小花费 dp[i][j] = dp[i-1][k] + (j-k) * c ...
- 洛谷P3004 宝箱Treasure Chest——DP
题目:https://www.luogu.org/problemnew/show/P3004 似乎有点博弈的意思,但其实是DP: f[i][j] 表示 i~j 的最优结果,就可以进行转移: 注意两个循 ...
- bzoj 1778: [Usaco2010 Hol]Dotp 驱逐猪猡【dp+高斯消元】
算是比较经典的高斯消元应用了 设f[i]为i点答案,那么dp转移为f[u]=Σf[v]*(1-p/q)/d[v],意思是在u点爆炸可以从与u相连的v点转移过来 然后因为所有f都是未知数,高斯消元即可( ...
- BZOJ 1778 [Usaco2010 Hol]Dotp 驱逐猪猡 ——期望DP
思路和BZOJ 博物馆很像. 同样是高斯消元 #include <map> #include <ctime> #include <cmath> #include & ...
最新文章
- 对于量子计算来说,99%的准确度足够吗?
- Using-更精彩更有用的做法-短签名
- libSVM 参数选择
- requests用法
- weather at Cambridge will be fine next week
- 北京内推 | ​美团无人车团队招聘视觉算法实习生
- JUnit 5 –动态测试
- insert into select 优化_数据库优化总结
- python定义二维数组_在python中定义二维数组
- OJ系统原理与实现:Python自动化测试另一个Python程序功能是否正确
- Modernizr 浏览器兼容功能检测
- Vray2.0材质手册
- 递归(recurse)与迭代(iteration)
- 笔记本移动热点打开电脑断网、台式机无线wifi打开电脑断网的解决办法
- 该虚拟机似乎正在使用中。如果该虚拟机未在使用,请按“获取所有权(T)”按钮获取它的所有权。
- vi/vim的一些干货命令及快捷键(跳转最后一行,跳转行末等)~舒服!!!
- zabbix3.4绘制网络拓扑图
- 解锁 Elastic 最新的数据采集模块 - Ingest manager 和 Elastic Agent
- STM32 USB 开发(一)HID Slave 通信
- asp.net后台代码如何通过动态的id给aspx中的html控件赋值