結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
![]() |
提出日時 | 2025-02-22 03:09:54 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,153 bytes |
コンパイル時間 | 4,652 ms |
コンパイル使用メモリ | 297,728 KB |
実行使用メモリ | 813,908 KB |
最終ジャッジ日時 | 2025-02-22 03:10:04 |
合計ジャッジ時間 | 10,053 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | MLE * 1 -- * 44 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using T = tuple<ll, ll, int>; ll Y; bool operator<(T& t1, T& t2) { return (Y - get<0>(t1)) * get<1>(t2) < (Y - get<0>(t2)) * get<1>(t1); } int main() { int N, M, P; cin >> N >> M >> P >> Y; vector<vector<pair<int, ll>>> G(N); for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; a--, b--; G[a].push_back({b, c}); G[b].push_back({a, c}); } map<int, ll> mp; for (int i = 0; i < P; i++) { ll d, e; cin >> d >> e; mp[d - 1] = e; } // (cost, e, to)を乗せる // cost/eの最大化 // (Y-cost1)*e2<(Y-cost2)*e1 ll ans{}; priority_queue<T> que; if (!mp.contains(0)) que.push({0, 1000000000, 0}); else que.push({0, mp[0], 0}); vector<ll> dist(N); while (!que.empty()) { auto [c, e, now] = que.top(); que.pop(); ans = max(ans, (Y - c) / e); for (auto&& [p, c2] : G[now]) { if (c + c2 > Y) continue; auto e2 = e; if (mp.contains(p)) e2 = mp[p]; T t2{c + c2, e2, p}; if (dist[p] > (c + c2) / e2) continue; que.push({t2}); } } cout << ans << endl; }