UVA - 10891 Game of Sum
来源:互联网 发布:王者霸域 纯净数据库 编辑:程序博客网 时间:2024/04/27 23:49
题目大意:给你n(最多100)个数,有A,B两个人,两个人都可以从这些数的左右两个边界取数,A先取,如果两个都是按最优策略取,那么最后A的分数比B的多多少.
解题思路:定义状态map[x][y][z]表示从x到y这段石子,z(0或1表示当前A取,或B取)能得到的最多的分数。
则状转移成,在x与y这个范围内的值的和减去在x和y在这个范围内z^1能取得的最多的分数,
#include <iostream>#include <cstring>using namespace std;int sum[105] = {0}, DP[105][105];int DPS(int i, int j) {int mi = 0;if (DP[i][j])return DP[i][j];for (int k = i; k < j; k++) {mi = min(DPS(i, k), mi);mi = min(DPS(k + 1, j), mi);}return DP[i][j] = sum[j] - sum[i-1] - mi;}int main() {int n;while (cin >> n && n) {memset(DP, 0, sizeof(DP));for (int i = 1; i <= n; i++) {cin >> sum[i];sum[i] += sum[i-1];}cout << 2 * DPS(1, n) - sum[n] << endl;}return 0;}
0 0
- uva 10891 Game of Sum
- UVA 10891 Game of Sum
- UVa 10891 Game of Sum
- Uva-10891-Game of Sum
- Uva 10891 Game of Sum
- Uva - 10891 - Game of Sum
- uva 10891 - Game of Sum
- uva 10891 game of sum
- UVA 10891 Game of Sum
- UVa 10891 - Game of Sum
- UVA 10891 Game of Sum
- uva 10891 - Game of Sum
- UVA - 10891 Game of Sum
- uva 10891 - Game of Sum
- uva 10891 - Game of Sum
- UVA 10891 Game of Sum
- UVA -10891 - Game of Sum
- uva 10891 - Game of Sum
- uva 10026 Shoemaker's Problem(排序)
- Linux系统启动过程
- BZOJ 2314 士兵的放置(play) 树形DP
- UVA - 10635 Prince and Princess
- Json的创建与android下的解析
- UVA - 10891 Game of Sum
- php 匹配/r/n 回车换行特殊符号
- IntentFilter
- UVA - 10905 Children's Game
- Ubuntu14.04配置php-5.6.6开发环境
- UVA - 11100 The Trip, 2007
- UVA - 1450 Airport
- UVA - 1418 WonderTeam
- 用Scrapy爬取所有上市公司的股票代码和名称