結果
問題 | No.2387 Yokan Factory |
ユーザー | mkawa2 |
提出日時 | 2023-08-10 16:20:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,486 ms / 5,000 ms |
コード長 | 1,639 bytes |
コンパイル時間 | 333 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 176,312 KB |
最終ジャッジ日時 | 2024-11-16 23:29:31 |
合計ジャッジ時間 | 23,998 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,736 KB |
testcase_01 | AC | 42 ms
52,736 KB |
testcase_02 | AC | 42 ms
52,736 KB |
testcase_03 | AC | 42 ms
52,992 KB |
testcase_04 | AC | 40 ms
52,864 KB |
testcase_05 | AC | 41 ms
52,608 KB |
testcase_06 | AC | 40 ms
52,736 KB |
testcase_07 | AC | 41 ms
52,736 KB |
testcase_08 | AC | 42 ms
52,608 KB |
testcase_09 | AC | 41 ms
52,864 KB |
testcase_10 | AC | 40 ms
52,608 KB |
testcase_11 | AC | 41 ms
52,736 KB |
testcase_12 | AC | 42 ms
52,736 KB |
testcase_13 | AC | 41 ms
52,480 KB |
testcase_14 | AC | 41 ms
52,608 KB |
testcase_15 | AC | 995 ms
125,440 KB |
testcase_16 | AC | 518 ms
120,448 KB |
testcase_17 | AC | 1,479 ms
176,312 KB |
testcase_18 | AC | 1,860 ms
125,948 KB |
testcase_19 | AC | 1,673 ms
114,944 KB |
testcase_20 | AC | 1,164 ms
103,752 KB |
testcase_21 | AC | 2,471 ms
131,840 KB |
testcase_22 | AC | 1,120 ms
103,612 KB |
testcase_23 | AC | 1,777 ms
118,016 KB |
testcase_24 | AC | 650 ms
98,720 KB |
testcase_25 | AC | 1,016 ms
98,800 KB |
testcase_26 | AC | 2,147 ms
126,032 KB |
testcase_27 | AC | 2,486 ms
132,424 KB |
testcase_28 | AC | 105 ms
77,440 KB |
testcase_29 | AC | 126 ms
77,316 KB |
testcase_30 | AC | 111 ms
77,440 KB |
testcase_31 | AC | 115 ms
76,800 KB |
testcase_32 | AC | 91 ms
76,160 KB |
testcase_33 | AC | 90 ms
76,032 KB |
testcase_34 | AC | 118 ms
77,012 KB |
testcase_35 | AC | 117 ms
77,184 KB |
testcase_36 | AC | 85 ms
74,368 KB |
testcase_37 | AC | 41 ms
53,120 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(1000005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = -1-(-1 << 63) md = 10**9+7 # md = 998244353 from heapq import * def dijkstra(to, root, m): n = len(to) dist = [inf]*n dist[root] = 0 hp = [(0, root)] while hp: d, u = heappop(hp) if d > dist[u]: continue for v, c, b in to[u]: if b < m: continue nd = d+c if dist[v] <= nd: continue dist[v] = nd heappush(hp, (nd, v)) return dist def binary_search(l, r, minimize): if minimize: l -= 1 else: r += 1 while l+1 < r: m = (l+r)//2 if ok(m) ^ minimize: l = m else: r = m if minimize: return r return l def ok(m): return dijkstra(to, 0, m)[-1] <= x n, m, x = LI() to = [[] for _ in range(n)] for _ in range(m): u, v, a, b = LI() u, v = u-1, v-1 to[u].append((v, a, b)) to[v].append((u, a, b)) ans=binary_search(0,10**9,False) if ans: print(ans) else: print(-1)