# 10891-game of Sum

Source: Internet
Author: User
`Description: game question. Both parties can obtain the sum of the values of several consecutive array elements on either side of the array, but cannot go from both sides at the same time, you can get the header from one side at a time. # include <cstdio> # include <cstring> # include <cstdlib> int N, sum; int arr [110]; int V [110] [110]; int min (int x, int y) {return x> Y? Y: X;} int dp (int x, int y) {If (V [x] [Y]> sum) return V [x] [Y]; int C = 0; For (INT I = x; I <Y; I ++) C = min (C, dp (X, I )); for (INT I = x + 1; I <= y; I ++) C = min (C, dp (I, y )); V [x] [Y] = arr [y]-Arr [x-1]-C; return V [x] [Y];} int main () {// freopen ("a.txt", "r", stdin); While (scanf ("% d", & N )! = EOF) {If (! N) break; arr [0] = 0; For (INT I = 1; I <= N; I ++) {scanf ("% d ", & amp; arr [I]); arr [I] + = arr [I-1];} memset (v,-127, sizeof (V )); sum = V [0] [0]; printf ("% d \ n", 2 * dp (1, N)-Arr [N]);} return 0 ;}`

Related Keywords:

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.