题目
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
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
提问时间:2021-03-29
答案
#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的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1求未知数x.1.4(x-9)=8
- 2已知四边形,BC>AB,BD平分角ABC,角A 加角C等于180度,证明AD=CD
- 3由两层单位膜构成的细胞器有____和____
- 4名去火车站搭公车行3分之2后然后换出租车车速提高1倍18分钟前到火车站公车平均速度35KM1时小名到火车站多
- 518.请选择适当的方法解方程:x的平方减4X减1=0
- 6which restaurant to go to 对白
- 7在△ABC中,AB=AC,BC=8,若△ABC的面积为8,则AB
- 8车床床身导轨的硬度应该是多少?
- 9there is no end
- 10一个圆柱与一个圆锥等底等高,它们的体积之差24立方米,圆柱的体积是_,圆锥的体积_.
热门考点
- 1作文题目是为了心中的那份母爱
- 28.8.9.12等于24
- 3静止在粗糙水平地面上的木箱,受一逐渐增大的水平推力F作用,而木箱仍然保持静止不动,则在这个过程中() A.木箱与地面间的摩擦力始终为0,B.木箱所受合力始终为0 C.木箱与地面间的摩擦力随F增大而增大
- 4队尾的士兵从队尾跑到队首又返回.发现队尾前进了75米.士兵的速度是队伍的3倍,士兵跑了多少米?队伍多少
- 5百分数就是分母是100的分数,它和分数表达的意义完全相同这句话说的对不对
- 6英语翻译
- 7初二英语作文:Anna和家人到新加坡度假,Anna玩得很尽兴,她给好友Jill寄了一张明信片.
- 82011届上海市黄浦区高三物理一模第18的解题过程?
- 9制取氢气的所有化学方程式
- 10-倒立漏斗式防倒吸的原理?