結果

問題 No.1 道のショートカット
ユーザー albicillaalbicilla
提出日時 2017-09-21 00:02:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 145,272 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 13:14:37
合計ジャッジ時間 6,538 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)

int N,C,V;
int S[1510],T[1510],Y[1510],M[1510];
int dp[51][310];
int main(){
  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];

  memset(dp,0x3f,sizeof(dp));
  rep(i,310)dp[1][i]=0;

  for(int i=0;i<V;i++){
    for(int j=0;j<=C;j++){

      //道があるか
        if(j-Y[i]>=0){
            dp[T[i]][j]=min(dp[T[i]][j],dp[S[i]][j-Y[i]]+M[i]);
        }
    }
  }
  //dpデバッグ用
  for(int yy=0;yy<=C;yy++){
    for(int xx=0;xx<V;xx++){
      cout<<dp[xx][yy]<<" ";
    }
    cout<<endl;
  }

  int ans=INF;
  rep(i,C+1)ans=min(ans,dp[N][i]);
  if(ans<1061109567)cout<<ans<<endl;
  else cout<<-1<<endl;


  return 0;
}
0