結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
![]() |
提出日時 | 2025-01-25 14:18:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 937 ms / 2,000 ms |
コード長 | 602 bytes |
コンパイル時間 | 314 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 147,292 KB |
最終ジャッジ日時 | 2025-01-25 23:15:52 |
合計ジャッジ時間 | 22,140 ms |
ジャッジサーバーID (参考情報) |
judge7 / judge10 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
n, m, p, y = map(int, input().split()) abc = [list(map(int, input().split())) for _ in range(m)] de = [list(map(int, input().split())) for _ in range(p)] g = [[] for _ in range(n+1)] for a, b, c in abc: g[a].append((b, c)) g[b].append((a, c)) s = [10**18+1]*(n+1) for d, e in de: s[d] = e import heapq q = [(-y, 1)] mx = [0]*(n+1) mx[1] = y ans = 0 while q: ny, nn = heapq.heappop(q) ny *= -1 if ny < mx[nn]: continue ans = max(ans, ny//s[nn]) for b, c in g[nn]: if mx[b] < ny - c: heapq.heappush(q, (c-ny, b)) mx[b] = ny - c print(ans)