結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
![]() |
提出日時 | 2025-01-25 13:18:56 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 622 bytes |
コンパイル時間 | 424 ms |
コンパイル使用メモリ | 12,032 KB |
実行使用メモリ | 348,052 KB |
最終ジャッジ日時 | 2025-01-25 22:43:52 |
合計ジャッジ時間 | 56,806 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 38 TLE * 7 |
ソースコード
from collections import deque, defaultdict from heapq import heappop, heappush INF = 1<<62 N, M, P, Y = map(int, input().split()) E = defaultdict(list) for _ in range(M): a, b, c = map(int, input().split()) a, b = a-1, b-1 E[a].append((b, c)) E[b].append((a, c)) vis = [INF]*N q = [(0, 0)] while q: cost, i = heappop(q) if vis[i] < cost: continue vis[i] = cost for j, c in E[i]: if vis[j] < cost+c: continue heappush(q, (cost+c, j)) ans = 0 for _ in range(P): d, e = map(int, input().split()) d = d-1 money = Y-vis[d] ans = max(ans, money//e) print(ans)