結果

問題 No.1449 新プロランド
ユーザー MZKiMZKi
提出日時 2021-03-31 15:01:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 1,628 bytes
コンパイル時間 1,396 ms
コンパイル使用メモリ 160,152 KB
実行使用メモリ 74,388 KB
最終ジャッジ日時 2023-08-25 16:47:05
合計ジャッジ時間 4,524 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,484 KB
testcase_01 AC 7 ms
6,928 KB
testcase_02 AC 16 ms
8,720 KB
testcase_03 AC 5 ms
6,968 KB
testcase_04 AC 5 ms
7,076 KB
testcase_05 AC 216 ms
70,284 KB
testcase_06 AC 121 ms
47,584 KB
testcase_07 AC 82 ms
50,328 KB
testcase_08 AC 158 ms
74,388 KB
testcase_09 AC 55 ms
17,892 KB
testcase_10 AC 89 ms
63,500 KB
testcase_11 AC 61 ms
70,428 KB
testcase_12 AC 149 ms
62,792 KB
testcase_13 AC 65 ms
26,692 KB
testcase_14 AC 65 ms
73,660 KB
testcase_15 AC 144 ms
53,952 KB
testcase_16 AC 89 ms
32,104 KB
testcase_17 AC 109 ms
46,028 KB
testcase_18 AC 4 ms
6,228 KB
testcase_19 AC 41 ms
55,820 KB
testcase_20 AC 3 ms
5,348 KB
testcase_21 AC 61 ms
50,164 KB
testcase_22 AC 15 ms
9,356 KB
testcase_23 AC 82 ms
67,912 KB
testcase_24 AC 42 ms
15,468 KB
testcase_25 AC 25 ms
13,412 KB
testcase_26 AC 5 ms
6,136 KB
testcase_27 AC 208 ms
73,508 KB
testcase_28 AC 91 ms
28,192 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] >= 10010)continue;
            if(chmin(d[x.to][t + T[v]], cst)){
                que.push({cst, {x.to, t + T[v]}});
            }
        }
    }
    ll ans = inf;
    rep(i, 10010)chmin(ans, d[n-1][i]);
    cout << ans << endl;
}
0