結果

問題 No.2354 Poor Sight in Winter
ユーザー titiatitia
提出日時 2023-06-17 01:39:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,087 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 81,200 KB
最終ジャッジ日時 2023-09-07 00:48:30
合計ジャッジ時間 9,915 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,368 KB
testcase_01 AC 77 ms
71,372 KB
testcase_02 AC 74 ms
71,460 KB
testcase_03 AC 73 ms
71,260 KB
testcase_04 AC 73 ms
71,064 KB
testcase_05 AC 73 ms
71,320 KB
testcase_06 AC 73 ms
71,280 KB
testcase_07 AC 73 ms
71,272 KB
testcase_08 AC 74 ms
71,392 KB
testcase_09 AC 82 ms
76,084 KB
testcase_10 AC 88 ms
76,472 KB
testcase_11 AC 262 ms
79,068 KB
testcase_12 AC 377 ms
80,292 KB
testcase_13 AC 402 ms
80,452 KB
testcase_14 AC 1,087 ms
81,092 KB
testcase_15 AC 453 ms
79,748 KB
testcase_16 AC 865 ms
81,200 KB
testcase_17 AC 602 ms
80,764 KB
testcase_18 AC 296 ms
81,116 KB
testcase_19 AC 460 ms
79,968 KB
testcase_20 AC 249 ms
79,308 KB
testcase_21 AC 175 ms
78,824 KB
testcase_22 AC 320 ms
79,240 KB
testcase_23 AC 242 ms
79,828 KB
testcase_24 AC 473 ms
80,420 KB
testcase_25 AC 264 ms
79,432 KB
testcase_26 AC 248 ms
79,232 KB
testcase_27 AC 140 ms
78,440 KB
testcase_28 AC 182 ms
78,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from heapq import heappop,heappush

N,K=map(int,input().split())
sx,sy,gx,gy=map(int,input().split())
P=[list(map(int,input().split())) for i in range(N)]

P.append([sx,sy])
P.append([gx,gy])

OK=2*10**5
NG=0

while OK>NG+1:
    mid=(OK+NG)//2

    DP=[K+1]*(N+2)
    DP[N]=0

    Q=[(0,N)]

    while Q:
        dis,ind=heappop(Q)

        x,y=P[ind]

        for i in range(N+2):
            z,w=P[i]

            dis=abs(x-z)+abs(y-w)
            dis-=mid

            k=max(0,(dis+mid-1)//mid)

            if DP[i]>DP[ind]+k:
                DP[i]=DP[ind]+k
                heappush(Q,(DP[i],i))

    if DP[N+1]<=K:
        OK=mid
    else:
        NG=mid

print(OK)

            
0