結果

問題 No.1211 円環はお断り
ユーザー vwxyzvwxyz
提出日時 2023-03-31 03:06:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,219 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 382,260 KB
最終ジャッジ日時 2023-10-23 16:43:08
合計ジャッジ時間 12,708 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
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

class Path_Doubling:
    def __init__(self,N,permutation):
        self.N=N
        self.permutation=permutation

    def Build_Next(self,K):
        self.k=K.bit_length()
        self.permutation_doubling=[[self.permutation[n]] for n in range(self.N)]
        for k in range(1,self.k):
            for n in range(self.N):
                self.permutation_doubling[n].append(self.permutation_doubling[self.permutation_doubling[n][k-1]][k-1])

    def Permutation_Doubling(self,N,K):
        for k in range(self.k):
            if K>>k&1:
                N=self.permutation_doubling[N][k]
        return N

def Bisect_Int(ok,ng,is_ok):
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if is_ok(mid):
            ok=mid
        else:
            ng=mid
    return ok

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]
def is_ok(ans):
    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]<ans:
            r+=1
        perm[l]=r
    PD=Path_Doubling(2*N+1,perm)
    PD.Build_Next(K)
    return False
ans=Bisect_Int(0,sum_A//K+1,is_ok)
print(ans)
0