結果
問題 | No.2739 Time is money |
ユーザー | ponjuice |
提出日時 | 2024-04-17 11:44:34 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 922 bytes |
コンパイル時間 | 2,373 ms |
コンパイル使用メモリ | 205,756 KB |
実行使用メモリ | 20,408 KB |
最終ジャッジ日時 | 2024-04-17 11:44:46 |
合計ジャッジ時間 | 11,418 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,624 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 188 ms
13,312 KB |
testcase_03 | AC | 361 ms
17,416 KB |
testcase_04 | AC | 178 ms
13,056 KB |
testcase_05 | AC | 240 ms
13,184 KB |
testcase_06 | AC | 325 ms
15,944 KB |
testcase_07 | AC | 441 ms
19,968 KB |
testcase_08 | AC | 371 ms
20,224 KB |
testcase_09 | AC | 383 ms
20,408 KB |
testcase_10 | AC | 340 ms
19,584 KB |
testcase_11 | AC | 354 ms
20,384 KB |
testcase_12 | AC | 325 ms
18,816 KB |
testcase_13 | AC | 342 ms
18,816 KB |
testcase_14 | AC | 294 ms
18,816 KB |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
ソースコード
#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; } }