結果

問題 No.1 道のショートカット
ユーザー togatogatogatoga
提出日時 2015-04-10 20:51:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,681 bytes
コンパイル時間 1,891 ms
コンパイル使用メモリ 88,284 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-22 12:03:14
合計ジャッジ時間 2,115 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>

#include <tuple>
#include <unordered_map>

#define mp       make_pair
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
int C;
int V;
int S[55];
int T[55];
int Y[55];
int M[55];
int dp[55][330];
int main(){
  cin >> N;
  cin >> C;
  cin >> V;
  for (int i = 0; i < V; i++){
    cin >> S[i];
  }
  for (int i = 0; i < V; i++){
    cin >> T[i];
  }
  for (int i = 0; i < V; i++){
    cin >> Y[i];
  }

  for (int i = 0; i < V; i++){
    cin >> M[i];
  }



  for (int i = 0; i < 55; i++){
    for (int j = 0; j < 330; j++){
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < N; i++){
    for (int k = 0; k < V; k++){
      if (S[k] - 1 == i){
        for (int j = 0; j <= C; j++){
          if (dp[i][j] < INF){
            int ni = T[k] - 1;
            int nj = Y[k] + j;
            if (nj <= C){
              dp[ni][nj] = min(dp[ni][nj], dp[i][j] + M[k]);
            }
          }
        }
      }
    }
  }
  int ans = INF;
  for (int j = 0; j <= C; j++){
    ans = min(ans, dp[N - 1][j]);
  }
  if (ans == INF){
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}
0