結果

問題 No.1211 円環はお断り
ユーザー 草苺奶昔草苺奶昔
提出日時 2023-03-11 17:15:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 107,700 KB
最終ジャッジ日時 2023-10-18 10:06:46
合計ジャッジ時間 10,470 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,688 KB
testcase_01 AC 38 ms
53,688 KB
testcase_02 AC 39 ms
53,688 KB
testcase_03 AC 40 ms
53,688 KB
testcase_04 AC 39 ms
53,688 KB
testcase_05 AC 39 ms
53,688 KB
testcase_06 AC 38 ms
53,688 KB
testcase_07 AC 44 ms
59,276 KB
testcase_08 AC 38 ms
53,688 KB
testcase_09 AC 48 ms
61,912 KB
testcase_10 AC 49 ms
61,928 KB
testcase_11 AC 48 ms
61,912 KB
testcase_12 AC 43 ms
59,264 KB
testcase_13 AC 221 ms
91,240 KB
testcase_14 AC 422 ms
96,768 KB
testcase_15 AC 253 ms
96,708 KB
testcase_16 AC 394 ms
107,324 KB
testcase_17 AC 90 ms
76,176 KB
testcase_18 AC 256 ms
93,812 KB
testcase_19 AC 109 ms
76,340 KB
testcase_20 AC 107 ms
76,800 KB
testcase_21 AC 99 ms
76,792 KB
testcase_22 AC 291 ms
91,564 KB
testcase_23 AC 331 ms
94,172 KB
testcase_24 AC 195 ms
84,820 KB
testcase_25 AC 76 ms
75,736 KB
testcase_26 AC 277 ms
98,308 KB
testcase_27 AC 191 ms
84,828 KB
testcase_28 AC 381 ms
99,688 KB
testcase_29 AC 250 ms
93,800 KB
testcase_30 AC 333 ms
100,036 KB
testcase_31 AC 159 ms
83,336 KB
testcase_32 AC 395 ms
104,032 KB
testcase_33 AC 440 ms
107,360 KB
testcase_34 AC 460 ms
107,360 KB
testcase_35 AC 437 ms
107,360 KB
testcase_36 AC 466 ms
107,372 KB
testcase_37 AC 441 ms
107,360 KB
testcase_38 AC 471 ms
107,408 KB
testcase_39 AC 468 ms
107,700 KB
testcase_40 AC 121 ms
107,700 KB
testcase_41 AC 38 ms
53,688 KB
testcase_42 AC 38 ms
53,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
from itertools import accumulate
import sys


input = lambda: sys.stdin.readline().rstrip("\r\n")
INF = int(4e18)

if __name__ == "__main__":
    n, k = map(int, input().split())
    nums = list(map(int, input().split()))

    def check(mid: int) -> bool:
        """每段>=mid,是否能分成>=k段"""
        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, lo=cur)
                if cur > start + n:
                    break
            else:
                return True
        return False

    preSum = [0] + list(accumulate(nums + nums))
    left, right = 1, (sum(nums) // k) + 1
    while left <= right:
        mid = (left + right) // 2
        if check(mid):
            left = mid + 1
        else:
            right = mid - 1
    print(right)
0