This is a 0 and a game, the highest score is only related to the sequence and who is the initiator.
D[I][J], which represents the highest score currently taken by the sequence of I to J, the transition state is the new interval and the other person takes, from which the minimum value is taken.
The minimum value of the decision can also be recursive.
#include <bits/stdc++.h>using namespacestd;Const intMX =101;intD[MX][MX],F[MX][MX],G[MX][MX];intSUM[MX];//#define LOCALintMain () {#ifdef LOCAL freopen ("In.txt","R", stdin);#endif intN; while(SCANF ("%d",&N), N) { for(inti =1; I <= N; i++) {scanf ("%d", sum+i); } for(inti =1; I <= N; i++) {G[i][i]= F[i][i] = D[i][i] =Sum[i]; Sum[i]+ = sum[i-1]; } for(intL =1; L < n; l++){ for(inti =1; I+l <= N; i++){ intj = i+L; D[I][J]= Sum[j]-sum[i-1]-min (0, Min (f[i+1][j],g[i][j-1])); F[I][J]= Min (d[i][j],f[i+1][j]); G[I][J]= Min (d[i][j],g[i][j-1]); }} printf ("%d\n", (d[1][n]<<1)-Sum[n]); } return 0;}
UVA10891 Game of Sum