結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
|
提出日時 | 2025-01-03 18:55:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 980 bytes |
コンパイル時間 | 368 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 219,776 KB |
最終ジャッジ日時 | 2025-01-25 21:57:20 |
合計ジャッジ時間 | 4,022 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge8 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 37 TLE * 8 |
ソースコード
#嘘解法1 from heapq import heappop, heappush INF = 10**18 def dijkstra(start, graph): n = len(graph) dist = [INF] * n dist[start] = 0 pq = [(0, start)] while pq: now_d, now_v = heappop(pq) # 既に見た頂点のチェックを忘れている for next_v, cost in graph[now_v]: next_d = now_d + cost if next_d < dist[next_v]: dist[next_v] = next_d heappush(pq, (next_d, next_v)) return dist N, M, P, Y = map(int, input().split()) graph = [[] for _ in range(N)] for _ in range(M): A, B, C = map(int, input().split()) graph[A - 1].append((B - 1, C)) graph[B - 1].append((A - 1, C)) shops = [INF] * N for _ in range(P): D, E = map(int, input().split()) shops[D - 1] = min(shops[D - 1], E) dist = dijkstra(0, graph) ans = 0 for i in range(N): if shops[i] < INF and dist[i] <= Y: ans = max(ans, (Y - dist[i]) // shops[i]) print(ans)