結果
問題 |
No.2354 Poor Sight in Winter
|
ユーザー |
![]() |
提出日時 | 2023-06-17 01:33:50 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 727 bytes |
コンパイル時間 | 479 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 80,340 KB |
最終ジャッジ日時 | 2024-06-24 19:19:59 |
合計ジャッジ時間 | 17,371 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 TLE * 2 |
ソースコード
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)