結果

問題 No.1 道のショートカット
ユーザー 夜
提出日時 2021-02-04 21:17:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,550 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 101,984 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 18:05:19
合計ジャッジ時間 8,233 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int dp[55][330];
int s[1550], t[1550], y[1550], m[1550];
vector<vector<tuple<int, int, int>>> vec(55);
int main() {
	int n, co, v;
	cin >> n >> co >> v;
	for (int i = 0; i < v; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < v; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < v; i++) {
		cin >> y[i];
	}
	for (int i = 0; i < v; i++) {
		cin >> m[i];
	}
	for (int i = 0; i < v; i++) {
		vec[s[i]].emplace_back(make_tuple(t[i], y[i], m[i]));
	}
	for (int i = 1; i <= v; i++) {
		for (int j = 0; j <= co; j++) {
			dp[i][j] = 1000000007;
		}
	}
	priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> que;
	que.push(make_tuple(0, 0, 1));
	while (!que.empty()) {
		tuple<int, int, int>t = que.top();
		que.pop();
		int x = get<2>(t);
		int y = get<1>(t);
		int z = get<0>(t);
		for (int i = 0; i < vec[x].size(); i++) {
			t = vec[x][i];
			int a = get<0>(t);
			int b = get<1>(t);
			int c = get<2>(t);
			if (y + b <= co && dp[a][y + b] > z + c) {
				que.push(make_tuple(z + c, y + b, a));
				dp[a][y + b] = z + c;
			}
		}
	}
	int ans = 1000000007;
	for (int i = 0; i <= co; i++) {
		if (ans > dp[n][i]) {
			ans = dp[n][i];
		}
	}
	if (ans == 1000000007) {
		cout << "-1" << endl;
	}
	else {
		cout << ans << endl;
	}
}

0