LightOJ 1031 - Easy Game(概率)
来源:互联网 发布:燃气水力计算软件 编辑:程序博客网 时间:2024/05/21 09:10
题目链接:LightOJ 1031 - Easy Game
代码
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 105;int N, A[maxn], S[maxn], dp[maxn][maxn];bool vis[maxn][maxn];void init () { scanf("%d", &N); for (int i = 1; i <= N; i++) scanf("%d", &A[i]); S[0] = 0; for (int i = 1; i <= N; i++) S[i] = S[i-1] + A[i]; memset(vis, false, sizeof(vis));}int solve (int l, int r) { int& ret = dp[l][r]; if (vis[l][r]) return ret; vis[l][r] = true; int sum = ret = S[r] - S[l-1]; for (int i = l; i < r; i++) { int ls = solve(l, i); int rs = solve(i+1, r); ret = max(sum - min(ls, rs), ret); } return ret;}int main () { int cas; scanf("%d", &cas); for (int kcas = 1; kcas <= cas; kcas++) { init(); int ans = solve(1, N); int ret = S[N] - ans; printf("Case %d: %d\n", kcas, ans - ret); } return 0;}
0 0
- LightOJ 1031 - Easy Game(概率)
- lightoj 1031 - Easy Game
- lightoj 1031 - Easy Game
- LightOJ 1031-Easy Game
- LightOJ 1031 - Easy Game (区间dp)
- lightoj 1031 - Easy Game(区间DP)
- Lightoj 1031 - Easy Game DP
- [LightOJ 1031]Easy Game[DP]
- LightOJ - 1031 Easy Game(区间DP)
- LightOJ 1031 Easy Game(区间DP)
- LightOJ 1031 - Easy Game【区间dp】
- lightoj 1031 - Easy Game 【区间dp】
- lightoj 1031 - Easy Game 【区间dp】
- lightoj 1031 Easy Game (区间dp 博弈)
- LightOJ 1031 Easy Game--区间dp
- lightoj 1031 - Easy Game 博弈类区间DP
- 1031 - Easy Game(博弈dp)
- LIGHTOJ 1027(概率 - 期望)
- 黑马程序员_自定义异常
- 把钱投资自己头脑上(三)
- 深入浅出LSTM神经网络 ------从卷积 递归网络 到长短时间记忆模型
- 用MVP架构开发Android应用
- liunx 2个tomcat
- LightOJ 1031 - Easy Game(概率)
- git 命令(分支)
- 黑马程序员_简单的售票系统
- Java包的命名规范
- C++基础::自制异常定位器
- GDI+ 使用指南(basic guiding of GDI plus )
- LightOJ 1032 - Fast Bit Calculations(dp)
- OS X下修改系统Hosts文件以及苹果手机如何host映射
- 黑马程序员_创建一个死锁