結果

問題 No.1449 新プロランド
ユーザー MZKiMZKi
提出日時 2021-03-31 15:15:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,688 ms / 2,000 ms
コード長 1,630 bytes
コンパイル時間 2,416 ms
コンパイル使用メモリ 159,708 KB
実行使用メモリ 74,336 KB
最終ジャッジ日時 2023-08-25 16:48:32
合計ジャッジ時間 16,000 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,384 KB
testcase_01 AC 25 ms
6,956 KB
testcase_02 AC 107 ms
8,560 KB
testcase_03 AC 9 ms
7,088 KB
testcase_04 AC 15 ms
7,012 KB
testcase_05 AC 1,688 ms
70,320 KB
testcase_06 AC 883 ms
47,712 KB
testcase_07 AC 485 ms
50,184 KB
testcase_08 AC 1,085 ms
74,336 KB
testcase_09 AC 411 ms
17,828 KB
testcase_10 AC 466 ms
63,552 KB
testcase_11 AC 129 ms
70,516 KB
testcase_12 AC 1,098 ms
62,704 KB
testcase_13 AC 466 ms
26,528 KB
testcase_14 AC 160 ms
73,600 KB
testcase_15 AC 1,071 ms
53,992 KB
testcase_16 AC 686 ms
32,092 KB
testcase_17 AC 779 ms
46,228 KB
testcase_18 AC 4 ms
6,220 KB
testcase_19 AC 42 ms
55,632 KB
testcase_20 AC 4 ms
5,688 KB
testcase_21 AC 279 ms
50,056 KB
testcase_22 AC 90 ms
9,388 KB
testcase_23 AC 360 ms
68,516 KB
testcase_24 AC 303 ms
15,824 KB
testcase_25 AC 186 ms
13,300 KB
testcase_26 AC 17 ms
6,248 KB
testcase_27 AC 1,589 ms
73,668 KB
testcase_28 AC 703 ms
28,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 P pair<int,int>
//#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using PiP = pair<ll, pair<ll, ll>>;

struct edge {
    ll to, cost;
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> G(n);
    vector<ll> T(n);
    rep(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }    
    rep(i, n)cin >> T[i];
    vector<vector<ll>> d(n, vector<ll>(100010, inf));
    priority_queue<PiP, vector<PiP>, greater<PiP>> que;
    d[0][0] = 0;
    que.push({0, {0, 0}});
    while(!que.empty()){
        PiP p = que.top();
        que.pop();
        ll v = p.second.first;
        ll t = p.second.second;
        if(p.first > d[v][t])continue;
        for(auto x : G[v]){
            ll cst = d[v][t] + T[v] + (x.cost / (t + T[v]));
            if(t + T[v] >= 100010)continue;
            if(chmin(d[x.to][t + T[v]], cst)){
                que.push({cst, {x.to, t + T[v]}});
            }
        }
    }
    ll ans = inf;
    rep(i, 100010)chmin(ans, d[n-1][i]);
    cout << ans << endl;
}
0