結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
|
提出日時 | 2025-09-05 20:36:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 298 ms / 2,000 ms |
コード長 | 925 bytes |
コンパイル時間 | 2,278 ms |
コンパイル使用メモリ | 206,980 KB |
実行使用メモリ | 20,960 KB |
最終ジャッジ日時 | 2025-09-05 20:36:30 |
合計ジャッジ時間 | 10,738 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using p = pair<ll, ll>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N, M, P, Y, ans = 0; cin >> N >> M >> P >> Y; vector graph(N, vector<p>()); while(M--) { ll A, B, C; cin >> A >> B >> C; A--, B--; graph[A].emplace_back(B, C); graph[B].emplace_back(A, C); } priority_queue<p, vector<p>, greater<p>> now; vector<ll> cost(N, LLONG_MAX); now.push({0, 0}); while(!now.empty()) { auto [w, n] = now.top(); now.pop(); if(cost[n] <= w) continue; cost[n] = w; for(auto [to, c] : graph[n]) { if(cost[to] <= w + c) continue; now.push({w + c, to}); } } while(P--) { ll D, E; cin >> D >> E; ans = max(ans, (Y - cost[D-1]) / E); } cout << ans << endl; }