HDU 4597 Play Game (interval dp, memory search)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.