結果

問題 No.2354 Poor Sight in Winter
ユーザー titiatitia
提出日時 2023-06-17 01:33:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 727 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 81,684 KB
最終ジャッジ日時 2023-09-07 00:43:45
合計ジャッジ時間 17,478 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,288 KB
testcase_01 AC 73 ms
70,972 KB
testcase_02 AC 73 ms
71,180 KB
testcase_03 AC 75 ms
71,288 KB
testcase_04 AC 72 ms
71,292 KB
testcase_05 AC 73 ms
71,388 KB
testcase_06 AC 72 ms
71,328 KB
testcase_07 AC 73 ms
71,348 KB
testcase_08 AC 73 ms
71,104 KB
testcase_09 AC 88 ms
76,008 KB
testcase_10 AC 93 ms
76,660 KB
testcase_11 AC 378 ms
80,212 KB
testcase_12 AC 386 ms
80,348 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 1,208 ms
80,960 KB
testcase_16 AC 1,621 ms
80,432 KB
testcase_17 AC 1,601 ms
80,600 KB
testcase_18 AC 613 ms
80,772 KB
testcase_19 AC 1,358 ms
80,740 KB
testcase_20 AC 681 ms
80,824 KB
testcase_21 AC 197 ms
78,900 KB
testcase_22 AC 399 ms
79,564 KB
testcase_23 AC 408 ms
79,904 KB
testcase_24 AC 873 ms
81,256 KB
testcase_25 AC 272 ms
79,748 KB
testcase_26 AC 256 ms
78,852 KB
testcase_27 AC 143 ms
78,484 KB
testcase_28 AC 182 ms
78,440 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=[1<<30]*(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