結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,684 KB
testcase_01 AC 38 ms
53,684 KB
testcase_02 AC 38 ms
53,684 KB
testcase_03 AC 38 ms
53,684 KB
testcase_04 WA -
testcase_05 AC 37 ms
53,684 KB
testcase_06 AC 37 ms
53,684 KB
testcase_07 AC 44 ms
59,276 KB
testcase_08 AC 38 ms
53,688 KB
testcase_09 AC 47 ms
61,908 KB
testcase_10 WA -
testcase_11 AC 47 ms
61,908 KB
testcase_12 WA -
testcase_13 AC 216 ms
91,236 KB
testcase_14 WA -
testcase_15 AC 261 ms
96,708 KB
testcase_16 AC 385 ms
107,324 KB
testcase_17 AC 113 ms
76,276 KB
testcase_18 WA -
testcase_19 AC 104 ms
76,344 KB
testcase_20 WA -
testcase_21 AC 98 ms
76,796 KB
testcase_22 AC 293 ms
91,564 KB
testcase_23 AC 348 ms
94,172 KB
testcase_24 AC 196 ms
84,820 KB
testcase_25 AC 77 ms
75,740 KB
testcase_26 AC 286 ms
98,308 KB
testcase_27 AC 194 ms
84,828 KB
testcase_28 WA -
testcase_29 AC 247 ms
93,800 KB
testcase_30 AC 341 ms
100,036 KB
testcase_31 AC 161 ms
83,336 KB
testcase_32 AC 374 ms
104,032 KB
testcase_33 AC 442 ms
107,360 KB
testcase_34 AC 445 ms
107,360 KB
testcase_35 AC 438 ms
107,360 KB
testcase_36 AC 460 ms
107,372 KB
testcase_37 AC 433 ms
107,360 KB
testcase_38 AC 493 ms
107,408 KB
testcase_39 AC 465 ms
107,700 KB
testcase_40 AC 1,198 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:
                    return False
        return True

    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