結果

問題 No.1 道のショートカット
ユーザー kyave3kyave3
提出日時 2014-12-03 20:36:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,233 bytes
コンパイル時間 2,036 ms
コンパイル使用メモリ 70,140 KB
実行使用メモリ 15,992 KB
最終ジャッジ日時 2023-09-22 11:48:14
合計ジャッジ時間 2,697 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
15,556 KB
testcase_01 AC 5 ms
15,572 KB
testcase_02 AC 5 ms
15,592 KB
testcase_03 AC 6 ms
15,624 KB
testcase_04 WA -
testcase_05 AC 6 ms
15,748 KB
testcase_06 AC 6 ms
15,752 KB
testcase_07 AC 6 ms
15,612 KB
testcase_08 AC 7 ms
15,816 KB
testcase_09 AC 7 ms
15,784 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 6 ms
15,840 KB
testcase_16 WA -
testcase_17 AC 6 ms
15,624 KB
testcase_18 AC 7 ms
15,728 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 7 ms
15,712 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 6 ms
15,684 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 6 ms
15,664 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 5 ms
15,688 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 5 ms
15,584 KB
testcase_43 AC 6 ms
15,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define INF (1L << 30)
#define LINF (1LL << 6
#define MM 1501
int S[MM], T[MM];
int edge[MM][MM], cost[MM][MM], dt[MM][MM];
int Y[MM], M[MM];
int dp[51][301];

int main() {
    int n,c,v;
    cin >> n >> c >> 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];
    
    fill((int*)edge, (int*)edge+MM*MM, 0);
    REP(i, v) {
        edge[S[i]][T[i]] = 1;
        cost[S[i]][T[i]] = Y[i];
        dt[S[i]][T[i]] = M[i];
    }
    
    
    fill((int*)dp, (int*)dp+51*301, INF);
    dp[1][0] = 0;
    FOR(i, 1, n+1) FOR(j, i+1, n+1) REP(cst, c+1) {
        if(edge[i][j] == 1)
            dp[j][cost[i][j]+cst] = min(dp[j][cost[i][j]+cst], dp[i][cst] + dt[i][j]);
    }
    int ans = INF;
    REP(i, c+1) ans = min(ans, dp[n][i]);
    cout << (ans==INF ? -1 : ans) << endl;
    
    return 0;
}
0