結果
問題 | No.2739 Time is money |
ユーザー | MZKi |
提出日時 | 2024-04-21 12:58:22 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 474 ms / 2,000 ms |
コード長 | 1,411 bytes |
コンパイル時間 | 4,872 ms |
コンパイル使用メモリ | 260,560 KB |
実行使用メモリ | 21,436 KB |
最終ジャッジ日時 | 2024-04-21 12:58:36 |
合計ジャッジ時間 | 12,818 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
9,472 KB |
testcase_01 | AC | 6 ms
9,472 KB |
testcase_02 | AC | 213 ms
15,488 KB |
testcase_03 | AC | 342 ms
19,628 KB |
testcase_04 | AC | 181 ms
15,232 KB |
testcase_05 | AC | 245 ms
16,768 KB |
testcase_06 | AC | 331 ms
19,976 KB |
testcase_07 | AC | 452 ms
19,968 KB |
testcase_08 | AC | 420 ms
20,224 KB |
testcase_09 | AC | 474 ms
20,352 KB |
testcase_10 | AC | 343 ms
19,712 KB |
testcase_11 | AC | 420 ms
20,352 KB |
testcase_12 | AC | 343 ms
18,944 KB |
testcase_13 | AC | 366 ms
18,816 KB |
testcase_14 | AC | 340 ms
18,816 KB |
testcase_15 | AC | 251 ms
21,436 KB |
testcase_16 | AC | 248 ms
19,008 KB |
testcase_17 | AC | 384 ms
20,608 KB |
testcase_18 | AC | 473 ms
20,736 KB |
testcase_19 | AC | 302 ms
21,040 KB |
ソースコード
#include<atcoder/all> using namespace atcoder; #include <bits/stdc++.h> template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}} template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}} #define ll long long #define double long double #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i,n) for(int i=1;i<=(n);i++) #define mod (ll)(1e9+7) #define inf (ll)(3e18+7) #define eps (double)(1e-9) #define pi (double) acos(-1) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() using namespace std; struct edge{ ll to, cost; }; vector<vector<edge>> G(200010); vector<ll> d(200010, inf); #define P pair<ll, int> void dijkstra(int s) { priority_queue<P, vector<P>, greater<P>>que; d[s] = 0; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if (d[v] < p.first)continue; rep(i, G[v].size()) { edge e = G[v][i]; if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } } int main() { ll n, m, x; cin >> n >> m >> x; rep(i, m){ ll u, v, c, t; cin >> u >> v >> c >> t; u--; v--; G[u].push_back({v, t * x + c}); G[v].push_back({u, t * x + c}); } dijkstra(0); if(d[n-1] == inf)cout << -1 << endl; else cout << (d[n-1] + x - 1) / x << endl; }