結果

問題 No.1 道のショートカット
ユーザー chlochlo
提出日時 2018-12-16 01:18:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,144 bytes
コンパイル時間 1,810 ms
コンパイル使用メモリ 172,788 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 13:25:19
合計ジャッジ時間 3,655 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 3 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
4,380 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,376 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,zeit;

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

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