結果
問題 | No.2739 Time is money |
ユーザー |
|
提出日時 | 2024-04-23 21:42:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,264 bytes |
コンパイル時間 | 1,914 ms |
コンパイル使用メモリ | 178,224 KB |
実行使用メモリ | 24,732 KB |
最終ジャッジ日時 | 2024-11-06 03:58:30 |
合計ジャッジ時間 | 10,237 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 WA * 3 TLE * 1 -- * 4 |
ソースコード
#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+7struct 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 << (int)(s[N-1] + (1 - 1e-10)) << endl;elsecout << -1 << endl;return 0;}