結果

問題 No.2601 Very Poor
ユーザー miya145592
提出日時 2024-01-12 23:20:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 119,296 KB
最終ジャッジ日時 2024-09-30 06:30:12
合計ジャッジ時間 4,731 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, X = map(int, input().split())
A = list(map(int, input().split()))
S = [0]
for a in A:
    S.append(S[-1]+a)
ans = 0
i = 0
j = 0
tmp = 0
while i<N:
    while j<i+N and tmp+A[j%N]<=X:
        tmp+=A[j%N]
        j+=1
    ans = max(ans, tmp)
    tmp-=A[i]
    i+=1
print(ans)
0