問題一覧 > 通常問題

No.2601 Very Poor

レベル : / AI推定難易度 : 675 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 153
作問者 : 👑 amentorimaru / テスター : cleantted 👑 seekworser
お気に入りにしたユーザー ProblemId : 10285 / 自分の提出
問題文最終更新日: 2024-01-08 13:25:32
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 414 (順位表) の他の問題:

Problem Statement

In a certain virtual space, restrictions may be imposed on avatars with too high a load.


Etowanyu-kun is trying to choose accessories to put on his avatar.

There are $N$ accessories, numbered from $1$ to $N$, displayed one by one in a circle on a table. Accessory $i+1$ is placed immediately to the left of accessory $i$, and accessory $1$ is placed immediately to the left of accessory $N$. The polygon count of accessory $i$ is $A_i$.

Etowanyu-kun wants to choose some consecutively arranged accessories among them and wear them, but if the total polygon count of the chosen accessories exceeds $X$, the avatar is judged to be high-load.

Find the maximum total polygon count when accessories are chosen so that the polygon count is as large as possible without being judged high-load.

Input

$N\ X$
$A_1 \ A_2 \ \dots A_N$

  • All inputs are integers.
  • $1 \le N \le 2\times 10^5$
  • $1 \le A_i,X \le 10^9$

Output

Output the answer.

Sample

Sample 1
Input
5 11
4 5 7 3 3
Output
10

Viewed from above, the accessories are arranged as shown below.

Etowanyu-kun can obtain a polygon count of $7+3=10$ by choosing the consecutive accessories $3,4$.

He can also wear accessories with a polygon count of $3+3+4=10$ by choosing the consecutive accessories $4,5,1$. Note that $N$ and $1$ are also adjacent.

Any way of wearing accessories with a total greater than $10$ is not possible: for example, choosing the consecutive accessories $5,1,2$ gives a polygon count of $3+4+5=12$, which exceeds $X=11$ and is judged to be high-load.

Choosing accessories $1,3$ gives a total of $4+7=11$, but note that a choice in which the accessories are not consecutive is not allowed.

Sample 2
Input
6 70000
108686 107161 117224 117236 78936 112374
Output
0

There may be cases where nothing can be worn.

Sample 3
Input
10 100
17 32 47 68 11 18 83 37 91 78
Output
97

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