結果

問題 No.1 道のショートカット
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-08-28 17:24:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,173 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 172,496 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-22 13:34:55
合計ジャッジ時間 11,286 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2,734 ms
4,376 KB
testcase_12 AC 18 ms
4,376 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

struct Edge {
    int to,cost, time;
};

vector<vector<Edge>> G;
int n, c, v;

ll dfs(int now,ll cost = 0) {
    if (cost > c) return LLINF;
    if (now == n - 1) return 0;
    ll ans = LLINF;
    for (Edge u : G[now]) {
        ll res = dfs(u.to, cost + u.cost);
        if (res == LLINF) continue;
        ans = min(ans,u.time+res);
    }
    return ans;
}

int main() {
    cin >> n >> c >> v;
    G.resize(n);
    vector<int> s(v),t(v),y(v),m(v);
    REP(i, v) cin >> s[i];
    REP(i, v) cin >> t[i];
    REP(i, v) cin >> y[i];
    REP(i, v) cin >> m[i];
    REP(i, v) {
        G[s[i] - 1].push_back({t[i] - 1,y[i],m[i]});
    }
    ll ans = dfs(0);
    if (ans == LLINF) {
        puts("-1");
    }
    else {
        cout << ans << endl;
    }
    getchar(); getchar();
}
0