結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 13:10:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 753 ms / 2,000 ms |
| コード長 | 956 bytes |
| コンパイル時間 | 1,517 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 120,588 KB |
| 最終ジャッジ日時 | 2025-01-25 22:35:24 |
| 合計ジャッジ時間 | 18,848 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 45 |
ソースコード
from heapq import heapify, heappop, heappush
N, M, P, Y = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
G[a].append((b, c))
G[b].append((a, c))
DE = []
for i in range(P):
d, e = map(int, input().split())
d -= 1
DE.append((d, e))
def dijk(G, start=0):
N = len(G)
dist = [10**18]*N
visited = [False]*N
que = []
dist[start] = 0
heappush(que, (0, start))
while que:
_, now = heappop(que)
if visited[now] == True:
continue
visited[now] = True
for to, weight in G[now]:
if dist[now] + weight < dist[to]:
dist[to] = dist[now] + weight
heappush(que, (dist[now]+weight, to))
return dist
stt = 0
dist = dijk(G, stt)
# print(dist)
ans = 0
for i in range(P):
d, e = DE[i]
x = (Y - dist[d]) // e
ans = max(ans, x)
print(ans)