結果

問題 No.1449 新プロランド
ユーザー MZKiMZKi
提出日時 2021-03-31 15:14:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 335 ms / 2,000 ms
コード長 1,627 bytes
コンパイル時間 2,523 ms
コンパイル使用メモリ 160,192 KB
実行使用メモリ 17,824 KB
最終ジャッジ日時 2023-08-25 16:48:21
合計ジャッジ時間 6,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 6 ms
4,376 KB
testcase_02 AC 23 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 335 ms
17,180 KB
testcase_06 AC 178 ms
12,384 KB
testcase_07 AC 97 ms
12,600 KB
testcase_08 AC 216 ms
17,824 KB
testcase_09 AC 84 ms
6,344 KB
testcase_10 AC 93 ms
15,748 KB
testcase_11 AC 27 ms
16,768 KB
testcase_12 AC 218 ms
15,556 KB
testcase_13 AC 97 ms
7,936 KB
testcase_14 AC 34 ms
17,620 KB
testcase_15 AC 216 ms
13,744 KB
testcase_16 AC 139 ms
8,924 KB
testcase_17 AC 157 ms
11,732 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 10 ms
13,916 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 56 ms
12,576 KB
testcase_22 AC 19 ms
4,428 KB
testcase_23 AC 73 ms
16,428 KB
testcase_24 AC 63 ms
5,756 KB
testcase_25 AC 36 ms
5,096 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 318 ms
17,608 KB
testcase_28 AC 145 ms
8,308 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>(20010, 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] >= 20010)continue;
            if(chmin(d[x.to][t + T[v]], cst)){
                que.push({cst, {x.to, t + T[v]}});
            }
        }
    }
    ll ans = inf;
    rep(i, 20010)chmin(ans, d[n-1][i]);
    cout << ans << endl;
}
0