結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
4,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,376 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 REPS(i,n) for (int i = 0; i <= (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define FORS(i,s,n) for (int i = (s); i <= (n); i++)
#define INF (1L << 30)
#define LINF (1LL << 6

int S[1500], T[1500];
int edge[51][51], cost[51][51], dist[51][51];
int Y[1500], M[1500];
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+51*51, 0);
    REP(i, v) {
        edge[S[i]][T[i]] = 1;
        cost[S[i]][T[i]] = Y[i];
        dist[S[i]][T[i]] = M[i];
    }
    
    
    fill((int*)dp, (int*)dp+51*301, INF);
    dp[1][0] = 0;
    FORS(i, 1, n) FORS(j, i+1, n) REPS(k, c) {
        if(dp[i][k] != INF && edge[i][j] == 1 && cost[i][j]+k <= c)
            dp[j][cost[i][j]+k] = min(dp[j][cost[i][j]+k], dp[i][k] + dist[i][j]);
    }
    int ans = INF;
    REP(i, c+1) ans = min(ans, dp[n][i]);
    cout << (ans==INF ? -1 : ans) << endl;
    
    return 0;
}
0