結果

問題 No.1449 新プロランド
ユーザー boutarouboutarou
提出日時 2021-03-31 15:57:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,371 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 209,096 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-25 16:49:43
合計ジャッジ時間 3,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
using ll = long long;
using P = pair<ll, ll>;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n, m; cin >> n >> m;
    vector<ll> a(m), b(m), c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
    }
    vector<ll> t(n);
    rep(i, n) cin >> t[i];
    vector<vector<P>> g(n);
    rep(i, m) {
        g[a[i]].push_back({b[i], c[i]});
        g[b[i]].push_back({a[i], c[i]});
    }
    const ll INF = 1e9;
    vector<ll> dist(n * (ll)1001, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[0 * (ll)1001 + t[0]] = t[0];
    que.push({t[0], t[0]});
    while (!que.empty()) {
        P now = que.top(); que.pop();
        ll nv = now.second, nc = now.first;
        if(nc > dist[nv]) continue;
        for (auto elem : g[nv / (ll)1001]) {
            ll nnv = elem.first * (ll)1001 + min((ll)1000, nv % (ll)1001 + t[elem.first]);
            ll nnc = nc + (elem.second + nv % (ll)1001 - 1) / (nv % (ll)1001) + t[elem.first];
            if (nnc < dist[nnv]) {
                dist[nnv] = nnc;
                que.push({nnc, nnv});
            }
        }
    }
    ll ans = INF;
    rep(i, (ll)1001) {
        ans = min(ans, dist[(n - 1) * (ll)1001 + i]);
    }
    cout << ans << endl;
    return 0;
}
0