結果
問題 | No.2354 Poor Sight in Winter |
ユーザー | flygon |
提出日時 | 2023-06-16 22:34:54 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,206 bytes |
コンパイル時間 | 666 ms |
コンパイル使用メモリ | 86,940 KB |
実行使用メモリ | 103,316 KB |
最終ジャッジ日時 | 2023-09-06 20:55:12 |
合計ジャッジ時間 | 10,914 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 95 ms
71,532 KB |
testcase_01 | AC | 94 ms
71,412 KB |
testcase_02 | AC | 93 ms
71,484 KB |
testcase_03 | RE | - |
testcase_04 | AC | 92 ms
71,432 KB |
testcase_05 | RE | - |
testcase_06 | AC | 92 ms
71,284 KB |
testcase_07 | AC | 92 ms
71,484 KB |
testcase_08 | AC | 93 ms
71,572 KB |
testcase_09 | AC | 111 ms
77,156 KB |
testcase_10 | AC | 110 ms
76,868 KB |
testcase_11 | AC | 470 ms
101,460 KB |
testcase_12 | AC | 455 ms
100,508 KB |
testcase_13 | AC | 670 ms
103,316 KB |
testcase_14 | AC | 728 ms
102,428 KB |
testcase_15 | AC | 635 ms
102,756 KB |
testcase_16 | AC | 710 ms
101,856 KB |
testcase_17 | AC | 670 ms
102,724 KB |
testcase_18 | AC | 377 ms
87,912 KB |
testcase_19 | AC | 522 ms
95,268 KB |
testcase_20 | AC | 400 ms
88,900 KB |
testcase_21 | AC | 185 ms
79,212 KB |
testcase_22 | AC | 309 ms
84,076 KB |
testcase_23 | AC | 317 ms
84,148 KB |
testcase_24 | AC | 468 ms
92,460 KB |
testcase_25 | RE | - |
testcase_26 | AC | 264 ms
81,556 KB |
testcase_27 | AC | 166 ms
78,424 KB |
testcase_28 | AC | 194 ms
79,980 KB |
ソースコード
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n,k = map(int,input().split()) sx,sy,gx,gy = map(int,input().split()) xy = [[sx,sy]] for i in range(n): xy.append(list(map(int,input().split()))) xy.append([gx,gy]) graph = [[] for i in range(n+2)] for i in range(n+2): xi,yi = xy[i] for j in range(n+2): xj,yj = xy[j] if i == j: continue graph[i].append([j,abs(xi-xj) + abs(yi-yj)]) #ダイクストラ法 def dijkstra(s,n, p): # sがスタート、nが頂点数 INF = 10**15 dist = [INF]*(n+1) que = [(0,s)] dist[s] = 0 while que: c,crr = heappop(que) if c > dist[crr]: continue for nxt, cost in graph[crr]: cnt = (cost-1)//p if dist[crr] + cnt < dist[nxt]: dist[nxt] = dist[crr] + cnt heappush(que,(dist[nxt],nxt)) return dist[-2] l = 0 r = 10**6 for i in range(40): m = (l+r)//2 cnt = dijkstra(0, n+2, m) if cnt <= k: r = m else: l = m print(r)