結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 13:51:29 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 750 bytes |
| コンパイル時間 | 657 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 92,288 KB |
| 最終ジャッジ日時 | 2025-01-25 23:01:39 |
| 合計ジャッジ時間 | 49,356 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 41 TLE * 4 |
ソースコード
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)