結果

問題 No.1211 円環はお断り
ユーザー vwxyzvwxyz
提出日時 2023-03-31 04:08:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 846 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 381,992 KB
最終ジャッジ日時 2023-10-23 17:46:39
合計ジャッジ時間 12,375 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,556 KB
testcase_01 AC 36 ms
53,556 KB
testcase_02 AC 37 ms
53,556 KB
testcase_03 AC 37 ms
53,556 KB
testcase_04 AC 38 ms
53,556 KB
testcase_05 AC 36 ms
53,556 KB
testcase_06 AC 36 ms
53,556 KB
testcase_07 AC 53 ms
64,352 KB
testcase_08 AC 37 ms
53,556 KB
testcase_09 AC 54 ms
66,188 KB
testcase_10 AC 52 ms
64,120 KB
testcase_11 AC 52 ms
64,108 KB
testcase_12 AC 41 ms
59,544 KB
testcase_13 AC 1,879 ms
381,992 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N,K=map(int,readline().split())
A=list(map(int,readline().split()))
sum_A=sum(A)
A=[0]+A*2
for i in range(1,2*N+1):
    A[i]+=A[i-1]
ok,ng=0,sum_A//K+1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    perm=[i for i in range(2*N+1)]
    r=0
    for l in range(2*N):
        while r<2*N and A[r]-A[l]<mid:
            r+=1
        perm[l]=r
    k=K.bit_length()
    perm_doub=[[perm[n]] for n in range(2*N+1)]
    for kk in range(1,k):
        for n in range(2*N+1):
            perm_doub[n].append(perm_doub[perm_doub[n][kk-1]][kk-1])
    for i in range(N):
        x=i
        for kk in range(k):
            if K>>kk&1:
                x=perm_doub[x][kk]
        if mid<A[i]:
            ng=mid
            break
        if x<=i+N:
            ok=mid
            break
    else:
        ng=mid
ans=ok
print(ans)
0