結果

問題 No.2601 Very Poor
ユーザー ShirotsumeShirotsume
提出日時 2024-01-12 21:38:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 110,056 KB
最終ジャッジ日時 2024-03-20 19:45:42
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
56,140 KB
testcase_01 AC 44 ms
56,140 KB
testcase_02 AC 44 ms
56,140 KB
testcase_03 AC 43 ms
56,140 KB
testcase_04 AC 43 ms
56,140 KB
testcase_05 AC 53 ms
64,828 KB
testcase_06 AC 56 ms
66,924 KB
testcase_07 AC 55 ms
66,928 KB
testcase_08 AC 55 ms
66,928 KB
testcase_09 AC 54 ms
64,836 KB
testcase_10 AC 52 ms
64,828 KB
testcase_11 AC 57 ms
66,920 KB
testcase_12 AC 55 ms
66,928 KB
testcase_13 AC 55 ms
66,928 KB
testcase_14 AC 54 ms
66,928 KB
testcase_15 AC 111 ms
110,056 KB
testcase_16 AC 111 ms
110,056 KB
testcase_17 AC 111 ms
110,056 KB
testcase_18 AC 120 ms
110,056 KB
testcase_19 AC 116 ms
110,056 KB
testcase_20 AC 110 ms
110,056 KB
testcase_21 AC 111 ms
110,056 KB
testcase_22 AC 113 ms
110,056 KB
testcase_23 AC 117 ms
110,056 KB
testcase_24 AC 112 ms
110,056 KB
testcase_25 AC 122 ms
110,056 KB
testcase_26 AC 112 ms
110,056 KB
testcase_27 AC 116 ms
110,056 KB
testcase_28 AC 119 ms
110,056 KB
testcase_29 AC 113 ms
110,056 KB
testcase_30 AC 112 ms
110,056 KB
testcase_31 AC 116 ms
110,056 KB
testcase_32 AC 115 ms
110,056 KB
testcase_33 AC 113 ms
110,056 KB
testcase_34 AC 116 ms
110,056 KB
testcase_35 AC 50 ms
64,712 KB
testcase_36 AC 55 ms
66,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n, x = mi()

a = li()

if sum(a) <= x:
    print(sum(a))
    exit()
    
a += a

ans = 0
right = 0
#n -> 数列の長さ
summ = 0
for left in range(2 * n):
    while right < 2 * n:
        summ += a[right]
        if summ <= x:
            right += 1
        else:
            summ -= a[right]
            break

    ans = max(ans, summ)

    if right == left:
        right += 1
    else:
        summ -= a[left]
print(ans)
0