結果

問題 No.1211 円環はお断り
ユーザー mkawa2mkawa2
提出日時 2023-11-08 21:26:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,505 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 104,964 KB
最終ジャッジ日時 2023-11-08 21:27:08
合計ジャッジ時間 18,519 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 AC 40 ms
53,460 KB
testcase_06 AC 39 ms
53,460 KB
testcase_07 AC 46 ms
61,200 KB
testcase_08 AC 41 ms
53,460 KB
testcase_09 AC 48 ms
61,708 KB
testcase_10 AC 45 ms
61,204 KB
testcase_11 AC 47 ms
61,712 KB
testcase_12 AC 43 ms
59,080 KB
testcase_13 AC 338 ms
89,144 KB
testcase_14 AC 470 ms
94,916 KB
testcase_15 AC 320 ms
94,820 KB
testcase_16 AC 684 ms
104,672 KB
testcase_17 AC 84 ms
75,912 KB
testcase_18 AC 323 ms
92,292 KB
testcase_19 AC 116 ms
76,184 KB
testcase_20 AC 100 ms
76,600 KB
testcase_21 AC 117 ms
76,592 KB
testcase_22 AC 363 ms
90,092 KB
testcase_23 AC 417 ms
92,476 KB
testcase_24 AC 320 ms
83,984 KB
testcase_25 AC 66 ms
75,632 KB
testcase_26 AC 335 ms
96,344 KB
testcase_27 AC 301 ms
84,000 KB
testcase_28 WA -
testcase_29 AC 412 ms
92,268 KB
testcase_30 AC 588 ms
97,812 KB
testcase_31 AC 234 ms
82,640 KB
testcase_32 AC 640 ms
101,208 KB
testcase_33 AC 817 ms
104,744 KB
testcase_34 AC 813 ms
104,740 KB
testcase_35 AC 769 ms
104,740 KB
testcase_36 AC 815 ms
104,764 KB
testcase_37 AC 827 ms
104,752 KB
testcase_38 AC 833 ms
104,784 KB
testcase_39 AC 851 ms
104,964 KB
testcase_40 AC 76 ms
99,700 KB
testcase_41 AC 37 ms
53,460 KB
testcase_42 AC 38 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 63)
md = 10**9+7
# md = 998244353

from bisect import *

n, k = LI()
aa = LI()
cs = [0]
for a in aa*2: cs.append(cs[-1]+a)

def binary_search(l, r, minimize):
    if minimize: l -= 1
    else: r += 1
    while l+1 < r:
        m = (l+r)//2
        if ok(m) ^ minimize: l = m
        else: r = m
    if minimize: return r
    return l

def ok(m):
    l, r = 0, n
    i = j = 0
    for _ in range(k):
        j = bisect_left(cs, cs[i]+m)
        if j > n: break
        if j-i < r-l: l, r = i, j
        i = j
    if j <= n: return True
    for si in range(l+1, r):
        i = si
        for _ in range(k):
            i = bisect_left(cs, cs[i]+m)
            if i > si+n: break
        if i <= si+n: return True
    return False

print(binary_search(1, sum(aa)//k, False))
0