結果
| 問題 |
No.2739 Time is money
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-17 11:42:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 958 bytes |
| コンパイル時間 | 2,154 ms |
| コンパイル使用メモリ | 205,584 KB |
| 最終ジャッジ日時 | 2025-02-21 02:47:41 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 TLE * 1 |
ソースコード
#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();
if (cst[p] != c) continue;
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;
}
}