結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
|
提出日時 | 2025-01-25 13:08:32 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,292 bytes |
コンパイル時間 | 2,943 ms |
コンパイル使用メモリ | 283,668 KB |
実行使用メモリ | 25,436 KB |
最終ジャッジ日時 | 2025-01-25 22:34:14 |
合計ジャッジ時間 | 13,885 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 WA * 31 |
ソースコード
#include <bits/stdc++.h> typedef long long ll; typedef std::pair<long long, long long> P; typedef std::priority_queue<P, std::vector<P>, std::greater<P>> PQ; int main() { long long n, m, p, y; std::cin >> n >> m >> p >> y; std::vector<std::vector<P>> path(n); std::vector<long long> h(n, -1); for (int i = 0; i < m; ++i) { ll a, b, c; std::cin >> a >> b >> c; --a, --b; path[a].push_back({b, c}); path[b].push_back({a, c}); } for (int i = 0; i < p; ++i) { ll d, e; std::cin >> d >> e; --d; h[d] = e; } std::vector<long long> dist(n, 1e17); dist[0] = 0; PQ pq; pq.push({0, 0}); while (!pq.empty()) { int udist = pq.top().first; int u = pq.top().second; pq.pop(); if (udist > dist[u]) continue; for (auto edge : path[u]) { int v = edge.first; int c = edge.second; if (dist[v] > udist + c) { dist[v] = udist + c; pq.push({udist + c, v}); } } } ll ans = 0; for (int i = 0; i < n; ++i) { if (h[i] == -1) continue; ll r = y - dist[i]; ans = std::max(ans, r / h[i]); } std::cout << ans << std::endl; }