Logo
(追記) (追記ここまで)

5945번 - Treasure Chest 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB2521017142.771%

문제

Bessie and Bonnie have found a treasure chest full of marvelous gold coins! Being cows, though, they can't just walk into a store and buy stuff, so instead they decide to have some fun with the coins.

The N (1 <= N <= 5,000) coins, each with some value C_i (1 <= C_i <= 5,000) are placed in a straight line. Bessie and Bonnie take turns, and for each cow's turn, she takes exactly one coin off of either the left end or the right end of the line. The game ends when there are no coins left.

Bessie and Bonnie are each trying to get as much wealth as possible for themselves. Bessie goes first. Help her figure out the maximum value she can win, assuming that both cows play optimally.

Consider a game in which four coins are lined up with these values:

 30 25 10 35

Consider this game sequence:

 Bessie Bonnie New Coin
Player Side CoinValue Total Total Line
Bessie Right 35 35 0 30 25 10
Bonnie Left 30 35 30 25 10
Bessie Left 25 60 30 10
Bonnie Right 10 60 40 --

This is the best game Bessie can play.

입력

  • Line 1: A single integer: N
  • Lines 2..N+1: Line i+1 contains a single integer: C_i

출력

  • Line 1: A single integer, which is the greatest total value Bessie can win if both cows play optimally.

제한

예제 입력 1

4
30
25
10
35

예제 출력 1

60

힌트

출처

Olympiad > USA Computing Olympiad > 2010-2011 Season > USACO December 2010 Contest > Silver 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /