結果

問題 No.1211 円環はお断り
ユーザー shotoyooshotoyoo
提出日時 2020-08-30 16:37:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,592 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 1,402 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 280,800 KB
最終ジャッジ日時 2023-08-15 10:06:53
合計ジャッジ時間 27,032 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,228 KB
testcase_01 AC 64 ms
71,368 KB
testcase_02 AC 63 ms
71,384 KB
testcase_03 AC 63 ms
71,256 KB
testcase_04 AC 62 ms
71,296 KB
testcase_05 AC 63 ms
71,212 KB
testcase_06 AC 64 ms
71,320 KB
testcase_07 AC 95 ms
76,428 KB
testcase_08 AC 67 ms
71,220 KB
testcase_09 AC 79 ms
76,360 KB
testcase_10 AC 89 ms
77,352 KB
testcase_11 AC 83 ms
76,624 KB
testcase_12 AC 72 ms
75,680 KB
testcase_13 AC 770 ms
197,264 KB
testcase_14 AC 956 ms
204,952 KB
testcase_15 AC 876 ms
191,832 KB
testcase_16 AC 1,184 ms
262,804 KB
testcase_17 AC 185 ms
80,288 KB
testcase_18 AC 948 ms
173,048 KB
testcase_19 AC 191 ms
81,048 KB
testcase_20 AC 215 ms
81,384 KB
testcase_21 AC 206 ms
81,516 KB
testcase_22 AC 695 ms
211,188 KB
testcase_23 AC 772 ms
197,448 KB
testcase_24 AC 491 ms
171,144 KB
testcase_25 AC 130 ms
78,096 KB
testcase_26 AC 922 ms
200,484 KB
testcase_27 AC 496 ms
187,648 KB
testcase_28 AC 1,079 ms
206,128 KB
testcase_29 AC 708 ms
188,636 KB
testcase_30 AC 1,028 ms
230,576 KB
testcase_31 AC 532 ms
152,076 KB
testcase_32 AC 1,144 ms
243,696 KB
testcase_33 AC 1,235 ms
260,056 KB
testcase_34 AC 1,224 ms
262,540 KB
testcase_35 AC 1,195 ms
261,736 KB
testcase_36 AC 1,176 ms
261,540 KB
testcase_37 AC 1,200 ms
280,652 KB
testcase_38 AC 697 ms
255,968 KB
testcase_39 AC 734 ms
256,132 KB
testcase_40 AC 1,592 ms
280,800 KB
testcase_41 AC 63 ms
71,440 KB
testcase_42 AC 63 ms
71,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
aa = a + a
s = sum(a)
def sub(x):
    if s<x*k:
        return False
    l = [None]*n
    v = a[0]
    j = 0
    for i in range(n):
        if j<i:
            j = i
            v = aa[i]
        while v<x:
            j += 1
            v += aa[j]
        l[i] = (j-i)+1
        v -= a[i]
    kk = 1
    dp = [l]
    while kk<n:
        tmp = [(dp[-1][i]+dp[-1][(dp[-1][i]+i)%n]) for i in range(n)]
        dp.append(tmp)
        kk *= 2
    vals = [0]*n
    index = list(range(n))
    for j in range(kk):
        if (k>>j)&1:
            for i in range(n):
                vals[i] += dp[j][index[i]]
                index[i] += dp[j][index[i]]
                index[i] %= n
#     print(l, dp, x)
    return any((vals[i]<=n) for i in range(n))
ll = 0
rr = s+1
while ll<rr-1:
    m = (ll+rr)//2
    if sub(m):
        ll = m
    else:
        rr = m
print(ll)
0