結果
問題 | No.2739 Time is money |
ユーザー | tobbie |
提出日時 | 2024-04-23 22:35:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,263 bytes |
コンパイル時間 | 1,951 ms |
コンパイル使用メモリ | 174,552 KB |
実行使用メモリ | 24,852 KB |
最終ジャッジ日時 | 2024-04-23 22:35:43 |
合計ジャッジ時間 | 12,053 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,752 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 189 ms
13,404 KB |
testcase_03 | AC | 356 ms
17,668 KB |
testcase_04 | AC | 181 ms
13,056 KB |
testcase_05 | AC | 247 ms
13,184 KB |
testcase_06 | AC | 340 ms
16,072 KB |
testcase_07 | AC | 437 ms
19,968 KB |
testcase_08 | AC | 439 ms
20,292 KB |
testcase_09 | AC | 433 ms
20,336 KB |
testcase_10 | AC | 349 ms
19,584 KB |
testcase_11 | AC | 414 ms
20,452 KB |
testcase_12 | AC | 351 ms
18,944 KB |
testcase_13 | AC | 353 ms
18,816 KB |
testcase_14 | WA | - |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long int; #define INF 1e18+7 struct Edge { int to; double dist; Edge(int to, double dist) : to(to), dist(dist) {} }; vector<double> dijkstra(int N, vector<vector<Edge>> &graph) { vector<double> distance(N, INF); priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> q; distance[0] = 0; q.push({0, 0}); while (!q.empty()) { pair<double, int> p = q.top(); q.pop(); double path_now = p.first; int p_now = p.second; for (Edge e : graph[p_now]) { double path_new = path_now + e.dist; int p_new = e.to; if (path_new < distance[p_new]) { distance[p_new] = path_new; q.push({path_new, p_new}); } } } return distance; } int main() { int N, M, X; cin >> N >> M >> X; vector<vector<Edge>> g(N); rep(i, M) { int u, v, C, T; cin >> u >> v >> C >> T; u--; v--; g[u].push_back({v, (double)C/X + T}); g[v].push_back({u, (double)C/X + T}); } vector<double> s = dijkstra(N, g); if (s[N-1] < INF) cout << (ll)((s[N-1]*X + (X-1))/X) << endl; else cout << -1 << endl; return 0; }