結果
問題 | No.2387 Yokan Factory |
ユーザー | mkawa2 |
提出日時 | 2023-08-10 16:20:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,718 ms / 5,000 ms |
コード長 | 1,639 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 176,676 KB |
最終ジャッジ日時 | 2024-04-28 09:35:01 |
合計ジャッジ時間 | 25,712 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
52,608 KB |
testcase_01 | AC | 43 ms
52,992 KB |
testcase_02 | AC | 43 ms
52,864 KB |
testcase_03 | AC | 43 ms
52,608 KB |
testcase_04 | AC | 44 ms
52,736 KB |
testcase_05 | AC | 43 ms
52,608 KB |
testcase_06 | AC | 42 ms
52,992 KB |
testcase_07 | AC | 43 ms
52,736 KB |
testcase_08 | AC | 43 ms
52,864 KB |
testcase_09 | AC | 43 ms
53,120 KB |
testcase_10 | AC | 44 ms
52,608 KB |
testcase_11 | AC | 42 ms
52,608 KB |
testcase_12 | AC | 44 ms
52,864 KB |
testcase_13 | AC | 43 ms
52,608 KB |
testcase_14 | AC | 43 ms
52,736 KB |
testcase_15 | AC | 1,071 ms
125,056 KB |
testcase_16 | AC | 545 ms
120,448 KB |
testcase_17 | AC | 1,588 ms
176,676 KB |
testcase_18 | AC | 1,994 ms
125,696 KB |
testcase_19 | AC | 1,859 ms
115,072 KB |
testcase_20 | AC | 1,362 ms
103,624 KB |
testcase_21 | AC | 2,718 ms
131,584 KB |
testcase_22 | AC | 1,435 ms
103,100 KB |
testcase_23 | AC | 2,035 ms
118,272 KB |
testcase_24 | AC | 717 ms
98,464 KB |
testcase_25 | AC | 1,154 ms
98,680 KB |
testcase_26 | AC | 2,308 ms
126,392 KB |
testcase_27 | AC | 2,662 ms
132,288 KB |
testcase_28 | AC | 110 ms
77,056 KB |
testcase_29 | AC | 135 ms
77,568 KB |
testcase_30 | AC | 122 ms
77,440 KB |
testcase_31 | AC | 121 ms
76,288 KB |
testcase_32 | AC | 99 ms
76,416 KB |
testcase_33 | AC | 98 ms
76,032 KB |
testcase_34 | AC | 125 ms
77,020 KB |
testcase_35 | AC | 122 ms
76,900 KB |
testcase_36 | AC | 89 ms
73,984 KB |
testcase_37 | AC | 43 ms
52,864 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)