結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
yamasaKit_
|
| 提出日時 | 2025-01-25 20:41:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 878 ms / 2,000 ms |
| コード長 | 1,274 bytes |
| コンパイル時間 | 710 ms |
| コンパイル使用メモリ | 82,732 KB |
| 実行使用メモリ | 127,412 KB |
| 最終ジャッジ日時 | 2025-01-26 00:08:35 |
| 合計ジャッジ時間 | 23,036 ms |
|
ジャッジサーバーID (参考情報) |
judge13 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 45 |
ソースコード
from collections import *
import heapq
from itertools import *
from functools import cache, partial
from pprint import pprint
import sys
from typing import Any, Final
try:
from icecream import ic
except ImportError: # Graceful fallback if IceCream isn't installed.
ic = lambda *a: None if not a else (a[0] if len(a) == 1 else a) # noqa
debug = partial(print, file=sys.stderr)
dpprint = partial(pprint, stream=sys.stderr)
sys.setrecursionlimit(10**6)
MOD = 998244353
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, b = a - 1, b - 1
G[a].append((c, b))
G[b].append((c, a))
T = [-1] * N
for _ in range(P):
d, e = map(int, input().split())
T[d - 1] = e
s = 0
dist = [float("inf")] * N
dist[s] = 0
used = [False] * N
used[s] = True
queue = []
for e in G[s]:
heapq.heappush(queue, e)
while queue:
v_cost, v = heapq.heappop(queue)
if used[v]:
continue
dist[v] = v_cost
used[v] = True
for u_cost, u in G[v]:
if not used[u]:
heapq.heappush(queue, (v_cost + u_cost, u))
ans = 0
for i in range(N):
if T[i] == -1:
continue
t = T[i]
dist_ = dist[i]
ans = max(ans, (Y - dist_) // t)
print(ans)
yamasaKit_