結果

問題 No.2601 Very Poor
ユーザー kemuniku
提出日時 2024-01-12 21:34:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 314 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 110,088 KB
最終ジャッジ日時 2024-09-27 21:28:26
合計ジャッジ時間 4,286 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

N,X = map(int,input().split())
A = list(map(int,input().split()))
A = A*2
if sum(A) <= X:
    print(sum(A))
    exit()
#半開区間を意識する
ans = 0
r = 0
now = 0
for l in range(2*N):
    while r < 2*N and now + A[r] <= X:
        now += A[r]
        r += 1
    ans = max(ans,now)
    now -= A[l]
print(ans)
0