結果

問題 No.2601 Very Poor
ユーザー player
提出日時 2024-01-14 23:48:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,736 KB
実行使用メモリ 140,592 KB
最終ジャッジ日時 2024-09-30 06:38:04
合計ジャッジ時間 5,262 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

n,x = map(int,input().split())
a = list(map(int,input().split()))

if sum(a) <= x:
    print(sum(a))
    exit()
    
b = a+a
acc = [0]
for i in b:
    acc.append(acc[-1]+i)

ans = 0
   
for i in range(n):
    ind = bisect_right(acc,acc[i]+x)
    tmp = acc[ind-1]-acc[i]
    ans = max(ans,tmp)
    
print(ans)
0