結果

問題 No.1 道のショートカット
ユーザー a_s_ka_s_k
提出日時 2023-11-07 04:08:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,097 bytes
コンパイル時間 2,382 ms
コンパイル使用メモリ 211,528 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-07 04:08:15
合計ジャッジ時間 4,860 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include"bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,m,n) for(ll i=(ll)m;i<(ll)n;i++)
#define Endl endl
#define pr(i,j) make_pair(i,j) 
const ll mod = 998244353;
const ll inf = 5e18;
const ld pi = 3.14159265358979;
struct T {
	ll to;
	ll time;
	ll cost;
};
int main() {
	ll n, c, v;
	cin >> n >> c >> v;
	vector<vector<ll>>dp(c + 1, vector<ll>(n,inf));
	vector<vector<T>> g(n);
	vector<ll>s(v), t(v), y(v), m(v);
	rep(i, 0, v) {
		cin >> s[i];
		s[i]--;
	}
	rep(i, 0, v) {
		cin >> t[i];
		t[i]--;
	}
	rep(i, 0, v) {
		cin >> y[i];
	}
	rep(i, 0, n) {
		cin >> m[i];
	}
	rep(i, 0, v) {
		T in = {};
		in.cost = y[i];
		in.time = m[i];
		in.to = t[i];
		g[s[i]].push_back(in);
	}
	dp[0][0] = 0;
	rep(i, 0, c + 1) {
		rep(j, 0, n) {
			rep(k, 0, g[j].size()) {
				if (i + g[j][k].cost <= c) {
					dp[i + g[j][k].cost][g[j][k].to] = min(dp[i + g[j][k].cost][g[j][k].to], dp[i][j]+g[j][k].time);
				}
			}
		}
	}
	ll ans = inf;
	rep(i, 0, c + 1) {
		ans = min(ans, dp[i][n - 1]);
	}
	if (ans == inf)cout << -1 << endl;
	else cout << ans << endl;
}
0