結果

問題 No.1 道のショートカット
ユーザー chlo27chlo27
提出日時 2018-12-16 02:30:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,220 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 170,472 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 13:25:39
合計ジャッジ時間 8,136 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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<int>> cost(51,vector<int>(51,INF));
vector<vector<int>> zeit(51,vector<int>(51,INF));

int solve(int town, int costlimit)
{
  if(costlimit < 0) return INF;
  if(town == 1) return 0;
  int mini=INF;
  rep1(i,town-1){
    if(zeit[town-i][town]!=INF && (costlimit-cost[town-i][town])>=0){
      mini=min(mini,solve(town-i,costlimit-cost[town-i][town])+zeit[town-i][town]);
    }
  }
  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){
    cost[s[i]][t[i]]=min(cost[s[i]][t[i]],y[i]);
    zeit[s[i]][t[i]]=min(zeit[s[i]][t[i]],m[i]);
  }

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