結果

問題 No.1 道のショートカット
ユーザー nenuon
提出日時 2017-08-01 01:21:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 888 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 89,308 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 16:32:49
合計ジャッジ時間 2,532 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
const int inf = 1e9;
int N,C,V;
int S[2000],T[2000],Y[2000],M[2000];
int dp[60][301];
int main()
{
  cin >> N >> C >> V;
  FOR(i,0,V) cin >> S[i];
  FOR(i,0,V) cin >> T[i];
  FOR(i,0,V) cin >> Y[i];
  FOR(i,0,V) cin >> M[i];
  FOR(i,0,60) FOR(j,0,301) dp[i][j] = inf;
  dp[1][0] = 0;
  FOR(i,0,51) {
    FOR(j,0,V) {
      FOR(k,Y[j],301) {
        dp[T[j]][k] = min(dp[T[j]][k], dp[S[j]][k-Y[j]] + M[j]);
      }
    }
  }
  int mn = inf;
  FOR(i,1,C+1) {
    mn = min(mn, dp[N][i]);
  }
  cout << (mn == inf ? -1 : mn) << endl;
  return 0;
}
0