Title Description
A sequence of length N ai, both operated in turn
Each operation is to select a prefix length greater than 1, and calculate its s, then replace it with a prefix of s, while the current player who scored s.
When only one element, the game is over.
Both sides want to maximize your score - the opponent's score to calculate this value.
Sample input and output
Input # 1
3 2 4 8
Output # 1
14
Input # 2
4 1 -7 -2 3
Output # 2
-3
Problem-solving ideas
Just get out of a dp qwq
AC Code
const int N=1e6; int n; int a[N],k; int main() { scanf("%d",&n); for(int i=1; i<=n; i++) { int hh; scanf("%d",&hh); and [i] = a [i- 1 ] + hh: } int years = a [n]; for ( int i = n- 1 ; i> = 1 ; i -) = k years years = max (years, [i] - k); printf("%d\n",k); return 0; }