結果

問題 No.2601 Very Poor
ユーザー ThetaTheta
提出日時 2024-02-02 19:25:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 849 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 54,948 KB
最終ジャッジ日時 2024-03-20 19:54:21
合計ジャッジ時間 19,528 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
9,984 KB
testcase_01 AC 32 ms
9,984 KB
testcase_02 AC 30 ms
9,984 KB
testcase_03 AC 30 ms
9,984 KB
testcase_04 AC 30 ms
9,984 KB
testcase_05 AC 35 ms
10,368 KB
testcase_06 AC 35 ms
10,368 KB
testcase_07 AC 35 ms
10,368 KB
testcase_08 AC 35 ms
10,368 KB
testcase_09 AC 35 ms
10,368 KB
testcase_10 AC 35 ms
10,368 KB
testcase_11 AC 35 ms
10,368 KB
testcase_12 AC 35 ms
10,368 KB
testcase_13 AC 35 ms
10,368 KB
testcase_14 AC 35 ms
10,368 KB
testcase_15 AC 837 ms
54,936 KB
testcase_16 AC 839 ms
54,948 KB
testcase_17 AC 845 ms
54,940 KB
testcase_18 AC 844 ms
54,936 KB
testcase_19 AC 845 ms
54,936 KB
testcase_20 AC 847 ms
54,936 KB
testcase_21 AC 840 ms
54,936 KB
testcase_22 AC 845 ms
54,936 KB
testcase_23 AC 839 ms
54,940 KB
testcase_24 AC 849 ms
54,940 KB
testcase_25 AC 845 ms
54,948 KB
testcase_26 AC 848 ms
54,936 KB
testcase_27 AC 847 ms
54,936 KB
testcase_28 AC 847 ms
54,944 KB
testcase_29 AC 846 ms
54,936 KB
testcase_30 AC 840 ms
54,944 KB
testcase_31 AC 842 ms
54,940 KB
testcase_32 AC 844 ms
54,936 KB
testcase_33 AC 848 ms
54,940 KB
testcase_34 AC 844 ms
54,936 KB
testcase_35 AC 35 ms
10,368 KB
testcase_36 AC 34 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate

import sys


def printe(*args, end="\n", **kwargs):
    print(*args, end=end, file=sys.stderr, **kwargs)


def main():
    N, X = map(int, input().split())
    A = list(map(int, input().split()))
    if sum(A) <= X:
        print(sum(A))
        return

    A_cp = [0]
    A_cp.extend(A)
    A_cp.extend(A)
    accum_A = list(accumulate(A_cp))
    printe(accum_A)
    max_value = 0
    for init_idx in range(N):
        lower = init_idx
        upper = init_idx + N
        while upper - lower > 1:
            mid = (upper + lower) // 2
            if accum_A[mid] - accum_A[init_idx] > X:
                upper = mid
            else:
                lower = mid
        max_value = max(max_value, accum_A[lower] - accum_A[init_idx])
    print(max_value)


if __name__ == "__main__":
    main()
0