結果

問題 No.1211 円環はお断り
ユーザー 草苺奶昔草苺奶昔
提出日時 2023-03-11 17:16:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 494 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 81,536 KB
実行使用メモリ 107,564 KB
最終ジャッジ日時 2023-10-18 10:07:23
合計ジャッジ時間 11,040 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,588 KB
testcase_01 AC 40 ms
53,588 KB
testcase_02 AC 40 ms
53,588 KB
testcase_03 AC 39 ms
53,588 KB
testcase_04 AC 40 ms
53,588 KB
testcase_05 AC 39 ms
53,588 KB
testcase_06 AC 40 ms
53,588 KB
testcase_07 AC 45 ms
59,152 KB
testcase_08 AC 39 ms
53,588 KB
testcase_09 AC 48 ms
61,748 KB
testcase_10 AC 49 ms
61,764 KB
testcase_11 AC 48 ms
61,748 KB
testcase_12 AC 43 ms
59,140 KB
testcase_13 AC 223 ms
91,076 KB
testcase_14 AC 436 ms
96,604 KB
testcase_15 AC 260 ms
96,544 KB
testcase_16 AC 403 ms
107,188 KB
testcase_17 AC 91 ms
76,016 KB
testcase_18 AC 261 ms
93,648 KB
testcase_19 AC 112 ms
76,180 KB
testcase_20 AC 111 ms
76,636 KB
testcase_21 AC 100 ms
76,628 KB
testcase_22 AC 304 ms
91,400 KB
testcase_23 AC 341 ms
94,008 KB
testcase_24 AC 203 ms
84,656 KB
testcase_25 AC 78 ms
75,580 KB
testcase_26 AC 286 ms
98,144 KB
testcase_27 AC 202 ms
84,664 KB
testcase_28 AC 389 ms
99,524 KB
testcase_29 AC 268 ms
93,636 KB
testcase_30 AC 353 ms
99,872 KB
testcase_31 AC 168 ms
83,172 KB
testcase_32 AC 423 ms
103,868 KB
testcase_33 AC 469 ms
107,224 KB
testcase_34 AC 481 ms
107,224 KB
testcase_35 AC 463 ms
107,224 KB
testcase_36 AC 490 ms
107,236 KB
testcase_37 AC 471 ms
107,224 KB
testcase_38 AC 489 ms
107,272 KB
testcase_39 AC 494 ms
107,564 KB
testcase_40 AC 120 ms
107,564 KB
testcase_41 AC 39 ms
53,588 KB
testcase_42 AC 38 ms
53,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
from itertools import accumulate


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