結果

問題 No.2739 Time is money
ユーザー t98slidert98slider
提出日時 2024-04-20 13:20:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 893 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 207,172 KB
実行使用メモリ 20,504 KB
最終ジャッジ日時 2024-04-20 13:20:51
合計ジャッジ時間 7,430 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 215 ms
17,440 KB
testcase_04 WA -
testcase_05 AC 139 ms
13,100 KB
testcase_06 AC 180 ms
15,956 KB
testcase_07 AC 256 ms
19,968 KB
testcase_08 AC 263 ms
20,188 KB
testcase_09 AC 260 ms
20,308 KB
testcase_10 WA -
testcase_11 AC 261 ms
20,292 KB
testcase_12 AC 175 ms
18,836 KB
testcase_13 AC 177 ms
18,816 KB
testcase_14 AC 163 ms
18,928 KB
testcase_15 AC 111 ms
17,936 KB
testcase_16 AC 113 ms
16,948 KB
testcase_17 AC 249 ms
20,500 KB
testcase_18 AC 263 ms
20,504 KB
testcase_19 AC 157 ms
17,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, u, v;
    ll x, c, t;
    cin >> n >> m >> x;
    vector<vector<pair<int,ll>>> g(n);
    for(int i = 0; i < m; i++){
        cin >> u >> v >> c >> t;
        u--, v--;
        g[u].emplace_back(v, c + t * x);
        g[v].emplace_back(u, c + t * x);
    }
    vector<ll> dp(n, 1ll << 62);
    priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;
    pq.emplace(0, 0);
    dp[0] = 0;
    while(!pq.empty()){
        tie(t, v) = pq.top();
        pq.pop();
        if(t > dp[v]) continue;
        for(auto [u, w] : g[v]){
            if(t + w >= dp[u]) continue;
            dp[u] = t + w;
            pq.emplace(dp[u], u);
        }
    }
    if(dp.back() >> 60) dp.back() = -x;
    cout << (dp.back() + x - 1) / x << '\n';
}
0