結果

問題 No.1 道のショートカット
ユーザー granddaifukugranddaifuku
提出日時 2019-12-07 20:48:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,284 bytes
コンパイル時間 1,609 ms
コンパイル使用メモリ 176,508 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-22 13:39:00
合計ジャッジ時間 14,466 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 TLE -
testcase_12 AC 30 ms
4,380 KB
testcase_13 AC 15 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 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>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int n, c;
vector<vector<tuple<int, int, int> > > g;
vector<int> res;

bool dfs(int s, int cost, int time) {
    if (cost > c) return false;
    res[s] = min(res[s], time);
    if (s == n - 1) return true;
    bool tmp = false;
    rep (i, g[s].size()) {
        int to, price, take;
        to = get<0>(g[s][i]), price = get<1>(g[s][i]), take = get<2>(g[s][i]);
        tmp |= dfs(to, cost + price, time + take);
    }
    return tmp;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int v;
    cin >> n >> c >> v;
    g.resize(n);
    res.resize(n, Inf);
    vector<int> s(v), t(v), y(v), m(v);
    rep (i, v) {
        cin >> s[i];
        s[i]--;
    }
    rep (i, v) {
        cin >> t[i];
        t[i]--;
    }
    rep (i, v) cin >> y[i];
    rep (i, v) cin >> m[i];
    rep (i, v) g[s[i]].push_back(make_tuple(t[i], y[i], m[i]));
    if (dfs(0, 0, 0)) cout << res[n - 1] << endl;
    else cout << -1 << endl;

    return 0;
}

0