HDU 4597 H - Play Game
来源:互联网 发布:淘宝优衣库代购可信吗 编辑:程序博客网 时间:2024/04/28 12:25
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define INF 0x3f3f3f3f#define EXP 1e-8#define UP(i,x,e) for(i=x;i<e;i++)#define DOWN(i,x,e) for(i=x;i>e;i--)#define Max(a,b,c) max(a,max(b,c))#define Men(name,num) memset(name,num,sizeof(name))const int maxn=25;int T,N,a[maxn],b[maxn],dp[maxn][maxn][maxn][maxn];int DFS(int fs,int fe,int ss,int se,int sum) { if(fs>fe&&ss>se)return 0;//当两个都达到了都没得选了,就返回零表示剩下的卡的值为零 if(dp[fs][fe][ss][se])return dp[fs][fe][ss][se];//已经存在,直接返回 int curmax=0; if(fs<=fe) { curmax=max(curmax,sum-DFS(fs+1,fe,ss,se,sum-a[fs]));//由于得到是当前最优解 curmax=max(curmax,sum-DFS(fs,fe-1,ss,se,sum-a[fe])); } if(ss<=se) { curmax=max(curmax,sum-DFS(fs,fe,ss+1,se,sum-b[ss])); curmax=max(curmax,sum-DFS(fs,fe,ss,se-1,sum-b[se])); } return dp[fs][fe][ss][se]=curmax;}int main() {#ifndef ONLINE_JUDGE freopen("D://imput.txt","r",stdin);#endif // ONLINE_JUDGE scanf("%d",&T); while(T--) { int sum=0; scanf("%d",&N); Men(dp,0); for(int i=1; i<=N; i++) { scanf("%d",&a[i]); sum+=a[i]; } for(int j=1; j<=N; j++) { scanf("%d",&b[j]); sum+=b[j]; } printf("%d\n",DFS(1,N,1,N,sum)); }}
0 0
- HDU 4597 H - Play Game
- HDU 4597 Play Game(2013吉林通化邀请赛H)
- hdu 4597 Play Game
- hdu 4597 play game
- hdu 4597Play Game
- HDU 4597 Play Game
- HDU 4597 Play Game
- HDU 4597 Play Game
- HDU 4597 Play Game
- HDU 4597 Play Game(搜索)
- HDU 4597 Play Game 2013 ACM-ICPC吉林通化全国邀请赛H题
- HDU 4597 Play Game 解题报告
- hdu 4597 Play Game (博弈dp)
- hdu 4597 Play Game(区间dp)
- HDU 4597 Play Game (对抗搜索)
- HDU 4597 Play Game (对抗搜索)
- HDU 4597 Play Game 记忆化搜索
- HDU 4597 Play Game(区间dp)
- HDU Children’s Queue
- 在ScrollView中嵌套ListView的问题
- 《软件调试艺术》读后感一
- hdu 4419 矩形面积并
- 黑马程序员——OC语言基础——与C的差异性
- HDU 4597 H - Play Game
- 面试经历1
- Spring 实现定时任务
- java开发工具快捷键使用大全(系列一)
- HDU 母牛的故事
- 经常逛的IT博客--持续更新ing.......
- 网络基础之TCP三次握手与四次挥手
- mysql 架构
- iOS 工作备注