結果

問題 No.1 道のショートカット
ユーザー kkslucy1kkslucy1
提出日時 2018-03-28 16:28:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,005 bytes
コンパイル時間 1,476 ms
コンパイル使用メモリ 155,624 KB
実行使用メモリ 814,628 KB
最終ジャッジ日時 2023-09-22 13:17:40
合計ジャッジ時間 6,243 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 696 ms
70,436 KB
testcase_12 WA -
testcase_13 AC 6 ms
4,856 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 RE -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 MLE -
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 <bits/stdc++.h>
using namespace std;

struct road {
	int s, t, y, m;
	bool operator<(const road& right) const {
		return s<right.s;
	}
};
int main() {
	int n, c, v;
	cin >> n >> c >> v;
	vector<road> r(v);
	for (int i = 0;i < v;i++) {
		cin >> r[i].s;
	}
	for (int i = 0;i < v;i++) {
		cin >> r[i].t;
	}
	for (int i = 0;i < v;i++) {
		cin >> r[i].y;
	}
	for (int i = 0;i < v;i++) {
		cin >> r[i].m;
	}

	sort(r.begin(), r.end());
	int mi = 1000000000;
	vector<queue<pair<int,int>>> q(v+1);
	int j = 0;
	q[1].push(pair<int,int>{ 0,0 });
	for (int i = 1;i < n;i++) {
		while (!q[i].empty()) {
			pair<int,int> qf = q[i].front();q[i].pop();
			for (int k = j;k < v&&r[k].s==i;k++) {
				if (qf.first + r[i].y <= c) {
					if (r[k].t == n) {
						mi = min(mi, qf.second + r[k].m);
					}
					else {
						q[r[k].t].push(pair<int,int>{qf.first + r[k].y,qf.second + r[k].m });
					}
				}
			}
		}
		for (;j < v&&r[j].s == i;j++);
	}

	cout << ((mi == 1000000000) ? -1 : mi) << endl;



	return 0;
}
0