結果

問題 No.1 道のショートカット
ユーザー michiharumichiharu
提出日時 2018-07-04 23:00:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,199 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 149,988 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 13:20:29
合計ジャッジ時間 4,587 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(void) {
    struct edge {
        int from, cost, time;
    };

    int N,C,V;
    cin >> N; cin >> C; cin >> V;
    int S[V],T[V],Y[V],M[V];
    for(int i=0; i<V; i++) cin >> S[i];
    for(int i=0; i<V; i++) S[i]--;
    for(int i=0; i<V; i++) cin >> T[i];
    for(int i=0; i<V; i++) T[i]--;
    for(int i=0; i<V; i++) cin >> Y[i];
    for(int i=0; i<V; i++) cin >> M[i];

    vector< vector <edge> > e(V);
    for(int i=0; i<V; i++) {
        edge memo;
        memo.from = S[i];
        memo.cost = Y[i];
        memo.time = M[i];
        e[T[i]].push_back(memo);
    }
    int dp[N][C];
    for(int i=0; i<N; i++) for(int j=0; j<C; j++) dp[i][j] = 1000000000;

    for(int i=0; i<N; i++) {
        if(i==0) {
            dp[0][0] = 0;
            continue;
        }
        for(int j=0; j<e[i].size(); j++) {
            int f=e[i][j].from, c=e[i][j].cost, t=e[i][j].time;
            for(int k=c; k<=C; k++) dp[i][k] = min(dp[i][k], dp[f][k-c] + t);
        }
    }

    int ans=1000000000;

    for(int i=0; i<C; i++) ans = min(ans, dp[N-1][i]);

    if(ans == INT_MAX) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}
0