ACM博弈问题,求给思路
题目
ACM博弈问题,求给思路
Problem Description
Alice
and Bob are playing a game.There are two piles of cards.There are N
cards in each pile,and each card has a score.They take turns
to pick up the top or bottom card from either pile,and the score
of the card will be added to his total score.Alice and Bob are both
clever enough,and will pick up cards to get as many scores as possible.
Do you know how many scores can Alice get if he picks up first?
Input
The first line contains an integer T (T≤100),indicating the number of cases.
Each case contains 3 lines.The first line is the N (N≤20).The second line contains N integer ai (1≤ai≤10000).The third line contains N integer bi (1≤bi≤10000).
Output
For each case,output an integer,indicating the most score Alice can get.
SampleInput
2
1
23
53
3
10 100 20
2 4 3
SampleOutput
53
105
答案
#include<cstdio>#include<algorithm>using namespace std;const int N = 23;int x[N][N][N][N], y[N][N][N][N];int n, A[N], B[N];int&nb...
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
热门考点
- 同学们排队做操,一排16人,队伍共长30米,前后两人之间的距离是多少米
- He goes to school at six every morning.(同义句)He( )( ) school at six every morning
- 现在中国繁荣程度相当于历史的那个时期
- 已知有理数a,b,c在数轴上的位置如图所示:_____b___a___-1______0___c____1 化简:|a+b|-|b-1|-|a-c|-|c-1|
- 一个梯形它的上底增加四米就变成一个正文形,面积也会比原来增加12平方米,原来梯形的面积是多少平方米?
- 工地上运来800色水泥,第一周用去5分之2,第二周用去8分之3.第一周用去多少包?第二周用去多少包?第一周比第二周用多少色?还剩仄多少包?
- 课桌下有一些书的英文,翻译一些
- 进行乙酰化反应时,一般采用醋酐做酰化剂,请问做酰化反应应一般情况下要注意哪些问题?
- 1、一罐250ml的纯牛奶体积为多少?该牛奶的密度是1.2*10³kg/m³,则牛奶质量为多少千克?
- 春日游湖上的第一句话运用修辞手法是什么