結果

問題 No.1 道のショートカット
ユーザー tana_twtrtana_twtr
提出日時 2014-12-01 18:15:05
言語 C++11
(gcc 11.4.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,324 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 77,740 KB
実行使用メモリ 814,536 KB
最終ジャッジ日時 2023-09-22 11:47:07
合計ジャッジ時間 4,605 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
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 <vector>
#include <algorithm>
using namespace std;

#define N 51
#define C 301
#define V 1501
#define INF (1 << 30)

struct Edge
{
	int t, y, m;
	
	Edge(int t, int y, int m)
		: t(t)
		, y(y)
		, m(m)
	{
	}
};

struct Y_M
{
	int y, m;

	Y_M(int y, int m)
		: y(y)
		, m(m)
	{
	}
};

int main()
{
	int n, c, v;

	cin >> n >> c >> v;

	int s[V], t[V], y[V], m[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];
	}

	vector<vector<Edge>> graph;
	graph.assign(n + 1, vector<Edge>());

	for (int i = 0; i < v; ++i)
	{
		graph[s[i]].emplace_back(t[i], y[i], m[i]);
	}

	vector<vector<Y_M>> yms;
	yms.assign(n + 1, vector<Y_M>());
	yms[1].emplace_back(0, 0);

	for (int i = 1; i <= n; ++i)
	{
		for (auto &e : graph[i])
		{
			for (auto &ym : yms[i])
			{
				if (ym.y + e.y > c) continue;

				yms[e.t].emplace_back(ym.y + e.y, ym.m + e.m);
			}
		}
	}

	if (yms[n].empty())
	{
		cout << "-1" << endl;
	}
	else
	{
		cout << min_element(yms[n].begin(), yms[n].end(), [](const Y_M &i, const Y_M &j){ return i.m < j.m; })->m << endl;
	}


	return 0;
}
0