UVA10891 Game of Sum

Source: Internet
Author: User
Tags define local

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

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.