結果

問題 No.1 道のショートカット
ユーザー koyoprokoyopro
提出日時 2015-02-03 01:44:58
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,591 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 77,036 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-22 11:55:58
合計ジャッジ時間 11,203 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3,471 ms
4,380 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,500 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 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 <iostream>
#include <math.h>
#include <vector>
#include <array>
#include <algorithm>
#include <queue>
#include <numeric>
#include <map>

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) //printf(__VA_ARGS__)

typedef pair<int, int> pos;
int pos::*x = &pos::first;
int pos::*y = &pos::second;

int dxy[] = {0, 1, 0, -1, 0};

/*================================*/

#define MAXV 1510
int N,C,V;
int S[MAXV], T[MAXV], Y[MAXV], M[MAXV];
vector2(int) routes;
// sからeまで、cost以下で行くのにかかる最低の時間
int dfp(int s, int e, int cost) {
    int min_cost = 1e8;
    if (s == e) return 0;
    for (int i : routes[s]) { // i: sから出る道の番号
        if (Y[i] > cost) continue; // コスト高くて通れない
        min_cost = min(min_cost, M[i] + dfp(T[i], e, cost-Y[i]));
    }
    return min_cost;
}

signed main()
{
    cin >> N >> C >> V;
    
    routes.resize(N+1);
    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) routes[S[i]].push_back(i);
    
    int ret = dfp(1, N, C);
    cout << ((ret >= 1e8) ? -1 : ret) << endl;
}
0