結果
| 問題 | No.3013 ハチマキ買い星人 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 13:51:29 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 1,530 ms / 2,000 ms |
| コード長 | 750 bytes |
| 記録 | |
| コンパイル時間 | 1,162 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 95,832 KB |
| 最終ジャッジ日時 | 2026-06-23 23:52:05 |
| 合計ジャッジ時間 | 36,984 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 45 |
ソースコード
from heapq import heapify, heappush, heappop
N, M, P, Y = map(int, input().split())
graph = [{} for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
graph[a][b] = c
graph[b][a] = c
headband = [None for _ in range(N)]
for _ in range(P):
d, e = map(int, input().split())
d -= 1
headband[d] = e
cost = [float('inf') for _ in range(N)]
cost[0] = 0
Q = [(0, 0)]
heapify(Q)
maximum = 0
while Q:
c, v = heappop(Q)
if c > cost[v]:
continue
if headband[v]:
maximum = max(maximum, max(Y - cost[v], 0) // headband[v])
for u in graph[v]:
d = c + graph[v][u]
if d < cost[u]:
cost[u] = d
heappush(Q, (d, u))
print(maximum)