結果
問題 |
No.2739 Time is money
|
ユーザー |
|
提出日時 | 2024-04-17 11:44:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 922 bytes |
コンパイル時間 | 2,326 ms |
コンパイル使用メモリ | 204,940 KB |
最終ジャッジ日時 | 2025-02-21 02:47:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 TLE * 1 -- * 4 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e18; int main(){ ll n, m, x; cin >> n >> m >> x; vector<vector<pair<int, ll>>> graph(n); for (int i = 0; i < m; i++) { ll u, v, c, t; cin >> u >> v >> c >> t; u--, v--; graph[u].emplace_back(v, t * x + c); graph[v].emplace_back(u, t * x + c); } priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q; vector<ll> cst(n, INF); q.push({0, 0}); cst[0] = 0; while (!q.empty()) { auto [c, p] = q.top(); q.pop(); for(auto [to, cp] : graph[p]){ if(cst[p] + cp < cst[to]){ cst[to] = cst[p] + cp; q.push({cst[to], to}); } } } if(cst[n - 1] == INF){ cout << -1 << endl; }else{ cout << (cst[n-1] + x - 1) / x << endl; } }