結果

問題 No.1 道のショートカット
ユーザー chlo27chlo27
提出日時 2018-12-16 19:47:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,443 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 173,908 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-09-22 13:25:28
合計ジャッジ時間 8,386 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 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,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
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>
#define rep(i, n) for(int i=0;i<(int)(n);++i)
#define rep1(i, n) for(int i=1;i<=(int)(n);++i)
#define irep(i, a, n) for(int i=a;i<(int)(n);++i)
#define rrep(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for(int i=(int)(n);i>=1;--i)
#define allrep(V, v) for(auto&& V:v)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const int INF=1<<29;
const double EPS=1e-9;
using namespace std;


int n,c,v;
vector<vector<vector<int>>> cost(51,vector<vector<int>>(51,vector<int>(1,INF)));
vector<vector<vector<int>>> zeit(51,vector<vector<int>>(51,vector<int>(1,INF)));

int solve(int town, int costlimit)
{
  if(costlimit < 0) return INF;
  if(town == 1) return 0;
  int mini=INF;
  rep1(i,town-1){
    rep(j,zeit[town-i][town].size()){
      if(zeit[town-i][town][j]!=INF && (costlimit-cost[town-i][town][j])>=0){
        mini=min(mini,solve(town-i,costlimit-cost[town-i][town][j])+zeit[town-i][town][j]);
      }
    }
  }
  return mini;
}

int main (void)
{
  cin>>n>>c>>v;
  vector<int> s(1501),t(1501),y(1501),m(1501);
  rep1(i,v) cin>>s[i];
  rep1(i,v) cin>>t[i];
  rep1(i,v) cin>>y[i];
  rep1(i,v) cin>>m[i];
  rep1(i,v){
    if(cost[s[i]][t[i]][0] == INF){
      cost[s[i]][t[i]][0]=y[i];
      zeit[s[i]][t[i]][0]=m[i];
    }else{
      cost[s[i]][t[i]].push_back(y[i]);
      zeit[s[i]][t[i]].push_back(m[i]);
    }
  }

  int ans=solve(n,c);
  cout << (ans<INF ? ans : -1) << endl;
  return 0;
}
0