結果
問題 |
No.2601 Very Poor
|
ユーザー |
|
提出日時 | 2024-02-02 19:25:04 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 926 ms / 2,000 ms |
コード長 | 831 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 55,792 KB |
最終ジャッジ日時 | 2024-09-30 06:41:37 |
合計ジャッジ時間 | 20,852 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
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()