結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
kohei0418
|
| 提出日時 | 2015-06-19 16:01:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,991 bytes |
| コンパイル時間 | 818 ms |
| コンパイル使用メモリ | 94,652 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-08 04:07:50 |
| 合計ジャッジ時間 | 1,944 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 16 WA * 24 |
ソースコード
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cassert>
#include <cstring>
#include <climits>
using namespace std;
#define FOR(k,a,b) for(int k=(a); k < (b); k++)
#define FORE(k,a,b) for(int k=(a); k <= (b); k++)
#define REP(k,a) for(int k=0; k < (a); k++)
#define ALL(c) (c).begin(), (c).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))
#define dump(x) cerr << #x << ": " << (x) << endl;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
const int INF = 1000 * 1000 * 1000;
const double EPS = 1e-10;
int main()
{
int N, C, V; cin >> N >> C >> V;
VI ss(V), ts(V), ys(V), ms(V);
REP(i, V) cin >> ss[i];
REP(i, V) cin >> ts[i];
REP(i, V) cin >> ys[i];
REP(i, V) cin >> ms[i];
VVI costs(N, VI(N, INF)), times(N, VI(N, INF));
REP(i, V) {
costs[ss[i]-1][ts[i]-1] = ys[i];
times[ss[i]-1][ts[i]-1] = ms[i];
}
VVI dp(N, VI(C+1, INF));
dp[0][0] = 0;
FOR(i, 1, N) {
FOR(j, 0, i) {
if(costs[j][i] < INF) {
int cost = costs[j][i];
int t = times[j][i];
FORE(c, 0, C) {
if(c + cost <= C) {
dp[i][c + cost] = min(dp[i][c + cost], dp[j][c] + t);
}
else {
break;
}
}
}
}
}
int res = INF;
FORE(c, 0, C) {
res = min(res, dp[N-1][c]);
}
if(res == INF) res = -1;
cout << res << endl;
return 0;
}
kohei0418