Блог пользователя Z3R0_IQ

Автор Z3R0_IQ, история, 3 года назад, По-английски

Please anyone give me some hints for solving this. problem Link : Lightoj 1031: Easy Game

Alice and Bob are playing a two player game. Initially, there are n integer numbers in an array and Alice and Bob get chances to take them alternatively. Each player can take one or more numbers from the left-end or the right-end of the array but cannot take from both ends at one turn. A player can take as many consecutive numbers as he/she wants during his time. The game ends when all numbers are taken from the array.

The point of each player is calculated by the summation of the numbers, which the player has taken. Each player tries to achieve as much points as possible. If both Alice and Bob play optimally and Alice starts the game, then how much more point can Alice get than Bob?

Input Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case contains a blank line and an integer N (1 ≤ N ≤ 100) denoting the size of the array. The next line contains N space separated integers. You may assume that no number will contain more than 4 digits.

Output For each test case, print the case number and the maximum difference Alice will be able to make after playing this game optimally.

Input 2 4 4 -10 -20 7 4 1 2 3 4

Output:

Case 1: 7 Case 2: 10

Полный текст и комментарии »

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится