結果

問題 No.1211 円環はお断り
ユーザー Yatharth Singh
提出日時 2024-07-13 15:12:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 864 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 108,452 KB
最終ジャッジ日時 2024-07-13 15:13:06
合計ジャッジ時間 17,094 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
from itertools import accumulate

n, k = map(int, input().split())
nums = list(map(int, input().split()))
preSum = [0] + list(accumulate(nums + nums))

def check(mid):
    max_ = bisect_right(preSum, mid)
    for start in range(max_):
        if start > n:
            break
        cur = start
        for _ in range(k):
            cur = bisect_left(preSum, preSum[cur] + mid)
            if cur > start + n:
                break
        else:
            return True
    return False

l, r = 0, (sum(nums) // k) + 1
while l <= r:
    mid = (l + r) // 2
    if check(mid):
        l = mid + 1
    else:
        r = mid - 1
print(r)
0