結果

問題 No.1 道のショートカット
ユーザー kikagekikage
提出日時 2019-07-16 21:03:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,078 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 60,168 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 13:31:08
合計ジャッジ時間 2,166 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
const int INF=1<<20;
int N,C,V;
//dp[k][m]:m円ちょうど使って1→kに行くときの最小単位時間
int dp[51][301];
vector<int> S,T,Y,M;
int main(){
  //入力処理
  cin >> N >> C >> V;
  for(int i=0;i<V;i++){
  	int s;cin >> s;S.push_back(s); 	
  }
  for(int i=0;i<V;i++){
  	int t;cin >> t;T.push_back(t); 	
  }
  for(int i=0;i<V;i++){
  	int y;cin >> y;Y.push_back(y); 	
  }
  for(int i=0;i<V;i++){
  	int m;cin >> m;M.push_back(m); 	
  }
  
  //dp処理開始
  for(int k=0;k<51;k++){for(int i=0;i<301;i++){dp[k][i]=INF;}}
  dp[1][0]=0;
  //Sが小さいものから順に処理
  for(int k=1;k<N;k++){
    for(int i=0;i<V;i++){
    	if(S[i]!=k) continue;
    	for(int m=Y[i];m-Y[i]<301;m++){
          dp[T[i]][m]=min(dp[T[i]][m],dp[S[i]][m-Y[i]]+M[i]);
        }
  	}
  }
  //C円以下で町Nに到着できる経路の中で、最小時間を探す。
  int ans=INF;
  for(int i=0;i<=C;i++){
  	ans=min(ans,dp[N][i]);
  }
  if(ans<INF)cout << ans << flush;
  else cout << -1 << flush;
  return 0;
}
0