結果

問題 No.1 道のショートカット
ユーザー stack9996stack9996
提出日時 2015-08-27 13:01:35
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,026 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 73,208 KB
実行使用メモリ 814,596 KB
最終ジャッジ日時 2023-09-22 12:27:21
合計ジャッジ時間 3,105 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <numeric>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <cmath>
#include <queue>

#define rep(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for(int i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
struct edge{ int to, time, cost; };

const int max = 51;
const int inf = (int)1e+9;

int n, c;
//P cost[max];
std::vector<edge> node[max];

int ans = inf;

void dfs(int i, int j, int k){
	if (i == n - 1){
		if (j < ans && k <= c)ans = j;
	}
	rep(p, node[i].size())dfs(node[i][p].to, j + node[i][p].time, k + node[i][p].cost);
}

int main(){
	int v;
	int s[51], t[51], y[51], m[51];
	std::cin >> n >> c >> v;
	rep(i, v)std::cin >> s[i];
	rep(i, v)std::cin >> t[i];
	rep(i, v)std::cin >> y[i];
	rep(i, v)std::cin >> m[i];
	rep(i, v){
		edge a;
		a.to = t[i] - 1;
		a.cost = y[i];
		a.time = m[i];
		node[s[i] - 1].push_back(a);
	}
	dfs(0, 0, 0);
	std::cout << (ans == inf ? -1 : ans) << std::endl;
	return 0;
}
0