結果
問題 | No.2739 Time is money |
ユーザー |
|
提出日時 | 2024-04-23 18:28:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,240 bytes |
コンパイル時間 | 1,785 ms |
コンパイル使用メモリ | 178,000 KB |
実行使用メモリ | 27,228 KB |
最終ジャッジ日時 | 2024-10-15 19:12:39 |
合計ジャッジ時間 | 12,984 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 WA * 10 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;using pil = pair<int, ll>;#define INF 1e18+7struct Edge {int to;ll dist;Edge(int to, ll dist) : to(to), dist(dist) {}};vector<ll> dijkstra(int N, vector<vector<Edge>> &graph) {vector<ll> distance(N, INF);priority_queue<pair<int, ll>,vector<pair<int, ll>>,greater<pair<int, ll>>> q;distance[0] = 0;q.push({0, 0});while (!q.empty()) {pair<int, ll> p = q.top();q.pop();int path_now = p.first;ll p_now = p.second;for (Edge e : graph[p_now]) {ll 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, (ll)C + (ll)T*X});g[v].push_back({u, (ll)C + (ll)T*X});}vector<ll> s = dijkstra(N, g);if (s[N-1] < INF)cout << (s[N-1] + (X-1)) / X << endl;elsecout << -1 << endl;return 0;}