problem Description
inch from Get as as Get if He picks up first?
Input
The first line contains a integer T (t≤3 is the N (n≤). The second line contains N integer ai (1≤ai≤10000). The third line contains N integer bi (1≤bi≤10000).
Output
Case get.
Sample Input
2 1 at - 3 Ten - - 2 4 3
Sample Output
- the
Source
ACM-ICPC Jilin Tonghua National Invitational--title reappearance
1 #pragmaComment (linker, "/stack:1024000000,1024000000")2#include <iostream>3#include <cstdio>4#include <cstring>5#include <cmath>6#include <math.h>7#include <algorithm>8#include <queue>9#include <Set>Ten#include <bitset> One#include <map> A#include <vector> -#include <stdlib.h> -#include <stack> the using namespacestd; - #definePI ACOs (-1.0) - #definell Long Long - #defineEPS 1e-10 + #defineMOD 1000000007 - #defineN 26 + #defineINF 1e12 A intsum1[ -],sum2[ -]; at inta[ -]; - intb[ -]; - intdp[ -][ -][ -][ -]; - intDfsintL1,intR1,intL2,intR2) - { - if(dp[l1][r1][l2][r2]!=-1) in returnDP[L1][R1][L2][R2]; - //if (l1>r1 && l2>r2) return dp[l1][r1][l2][r2]=0; to intsum=0; + intans=0; - if(l1<=R1) the { *Sum+=sum1[r1]-sum1[l1-1]; $ }Panax Notoginseng if(l2<=R2) - { thesum+=sum2[r2]-sum2[l2-1]; + } A if(l1<=R1) the { +Ans=max (Ans,sum-min (DFS (l1+1, R1,L2,R2), DFS (l1,r1-1, L2,R2))); - } $ if(l2<=R2) $ { -Ans=max (Ans,sum-min (DFS (l1,r1,l2+1, r2), DFS (l1,r1,l2,r2-1))); - } the returndp[l1][r1][l2][r2]=ans; - }Wuyi intMain () the { - intT; Wu intN; -Cin>>T; About while(t--) $ { -Cin>>N; -sum1[0]=sum2[0]=0; - for(intI=1; i<=n;i++) A { +scanf"%d",&a[i]); thesum1[i]=sum1[i-1]+A[i]; - } $ for(intI=1; i<=n;i++) the { thescanf"%d",&b[i]); thesum2[i]=sum2[i-1]+B[i]; the } -memset (dp,-1,sizeof(DP)); inprintf"%d\n", DFS (1N1, N)); the } the return 0; About}
View Code
HDU 4597 Play Game (interval dp, memory search)