結果

問題 No.1211 円環はお断り
ユーザー shotoyooshotoyoo
提出日時 2020-08-30 16:37:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,737 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 279,552 KB
最終ジャッジ日時 2024-05-02 21:38:05
合計ジャッジ時間 26,974 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
52,096 KB
testcase_01 AC 42 ms
52,096 KB
testcase_02 AC 41 ms
52,096 KB
testcase_03 AC 42 ms
52,224 KB
testcase_04 AC 44 ms
51,968 KB
testcase_05 AC 41 ms
52,608 KB
testcase_06 AC 41 ms
52,224 KB
testcase_07 AC 62 ms
64,000 KB
testcase_08 AC 41 ms
51,968 KB
testcase_09 AC 61 ms
64,000 KB
testcase_10 AC 68 ms
66,560 KB
testcase_11 AC 64 ms
65,408 KB
testcase_12 AC 49 ms
59,136 KB
testcase_13 AC 828 ms
203,904 KB
testcase_14 AC 1,026 ms
193,664 KB
testcase_15 AC 966 ms
201,472 KB
testcase_16 AC 1,283 ms
261,632 KB
testcase_17 AC 200 ms
80,128 KB
testcase_18 AC 1,037 ms
172,544 KB
testcase_19 AC 188 ms
79,488 KB
testcase_20 AC 216 ms
81,152 KB
testcase_21 AC 211 ms
80,384 KB
testcase_22 AC 748 ms
193,664 KB
testcase_23 AC 821 ms
195,584 KB
testcase_24 AC 512 ms
164,352 KB
testcase_25 AC 129 ms
76,928 KB
testcase_26 AC 1,018 ms
199,040 KB
testcase_27 AC 529 ms
170,240 KB
testcase_28 AC 1,206 ms
203,648 KB
testcase_29 AC 796 ms
196,864 KB
testcase_30 AC 1,101 ms
229,888 KB
testcase_31 AC 567 ms
155,648 KB
testcase_32 AC 1,199 ms
228,992 KB
testcase_33 AC 1,321 ms
261,120 KB
testcase_34 AC 1,315 ms
261,888 KB
testcase_35 AC 1,292 ms
260,608 KB
testcase_36 AC 1,274 ms
260,352 KB
testcase_37 AC 1,333 ms
279,552 KB
testcase_38 AC 751 ms
262,144 KB
testcase_39 AC 782 ms
262,400 KB
testcase_40 AC 1,737 ms
279,296 KB
testcase_41 AC 42 ms
52,480 KB
testcase_42 AC 42 ms
52,224 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