結果

問題 No.1 道のショートカット
ユーザー SakaTakuSakaTaku
提出日時 2020-08-26 00:02:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 749 bytes
コンパイル時間 2,920 ms
コンパイル使用メモリ 168,288 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-24 04:59:48
合計ジャッジ時間 12,656 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const int INF=1e9;
struct edge{int end,cost,time;};
vector<vector<edge>>G(50);
int ans=INF;
int n,c,v;
void dfs(int v,int c,int t){
   if(v==n-1)ans=min(ans,t);
   for (auto &&i : G[v]){
      if(c<i.cost)continue;
      dfs(i.end,c-i.cost,t+i.time);
   }
}
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cin>>n>>c>>v;
   vector<int>S(v),T(v),Y(v),M(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];
   rep(i,v){
      edge e;
      e.end=T[i]-1;e.cost=Y[i];e.time=M[i];
      G[S[i]-1].push_back(e);
   }
   dfs(0,c,0);
   if(ans==INF)cout<<-1<<endl;
   else cout<<ans<<endl;
}
0