結果

問題 No.1449 新プロランド
ユーザー MZKiMZKi
提出日時 2021-03-31 15:02:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,675 ms / 2,000 ms
コード長 1,629 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 159,700 KB
実行使用メモリ 74,404 KB
最終ジャッジ日時 2023-08-25 20:16:43
合計ジャッジ時間 15,744 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,412 KB
testcase_01 AC 26 ms
7,132 KB
testcase_02 AC 106 ms
8,712 KB
testcase_03 AC 9 ms
7,068 KB
testcase_04 AC 14 ms
7,068 KB
testcase_05 AC 1,675 ms
70,360 KB
testcase_06 AC 863 ms
47,740 KB
testcase_07 AC 472 ms
50,032 KB
testcase_08 AC 1,068 ms
74,404 KB
testcase_09 AC 405 ms
17,744 KB
testcase_10 AC 459 ms
63,444 KB
testcase_11 AC 127 ms
70,372 KB
testcase_12 AC 1,086 ms
62,628 KB
testcase_13 AC 458 ms
26,616 KB
testcase_14 AC 156 ms
73,508 KB
testcase_15 AC 1,059 ms
53,948 KB
testcase_16 AC 678 ms
32,144 KB
testcase_17 AC 768 ms
46,140 KB
testcase_18 AC 4 ms
6,340 KB
testcase_19 AC 40 ms
55,496 KB
testcase_20 AC 4 ms
5,420 KB
testcase_21 AC 273 ms
50,036 KB
testcase_22 AC 90 ms
9,436 KB
testcase_23 AC 352 ms
68,052 KB
testcase_24 AC 291 ms
15,524 KB
testcase_25 AC 181 ms
13,464 KB
testcase_26 AC 16 ms
6,332 KB
testcase_27 AC 1,561 ms
73,528 KB
testcase_28 AC 698 ms
28,096 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, 10010)chmin(ans, d[n-1][i]);
    cout << ans << endl;
}
0