問題一覧 > 通常問題

No.973 Party Entertainment

レベル : / AI推定難易度 : 1650 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 52
作問者 : 沙耶花 / テスター : shibh308
お気に入りにしたユーザー ProblemId : 3636 / 自分の提出
問題文最終更新日: 2020-08-17 15:49:50
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 234 (順位表) の他の問題:

Problem Statement

A and B held a party.
They are standing on the stage at the front of the party venue, and right in front of them is a table that is long from left to right.

On the table, $N$ cream puffs are arranged in a row.
The $i$-th cream puff from the left (as seen from the stage) has a nutritional value of $a_i$ kilocalories.

They decided to play a game as entertainment for the party.
Starting with A, they take turns choosing and performing one of the following operations.

  • Eat one or more cream puffs in consecutive positions, including the cream puff at the left end (as seen from the stage)
  • Eat one or more cream puffs in consecutive positions, including the cream puff at the right end (as seen from the stage)
However, a cream puff cannot be eaten partially (for example, only one and a half of them).

Also, they believe a rumor that "taking in more than $X$ kilocalories of nutrition at one time makes you fat."
Since they are devoting their lives to dieting,
they make sure that the total nutritional value of the cream puffs eaten during a single turn of their own never exceeds $X$ kilocalories.

The person who eats the last cream puff loses and has to pay the cost of holding the party.
Determine who wins when both of them act optimally with the aim of winning.

Input

$N\ X$
$a_1\ a_2\ ...\ a_N$

  • $1 \le N \le 5000$
  • $1 \le X \le 10^9$
  • $ 1 \le a_i \le X$
  • All inputs are integers

Output

Print "A" if A wins, and "B" if B wins.
Print a newline at the end.

Sample

Sample 1
Input
3 3
1 2 3
Output
A

If A first eats the 2 cream puffs including the one at the left end,
B will inevitably eat the last one.

Sample 2
Input
1 100
100
Output
B

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。