結果

問題 No.1 道のショートカット
ユーザー obaoba
提出日時 2014-11-24 01:03:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,050 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 76,012 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-22 11:46:37
合計ジャッジ時間 2,227 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef struct data{
	int money;
	int time;
}data;

int N, C, V;
int S[1500], T[1500], Y[1500], M[1500];
map<int, map<int,data> > keiro;

int loop(int pos, int money, int time, int min_time){
	if(money<0 || (min_time<time && min_time!=-1)){
		return -1;
	}
	if(pos == N){
		return time;
	}
	for(int i=1; i<=N; i++){
		if(keiro[pos].find(i) != keiro[pos].end()){
			int tmp = loop(i, money-keiro[pos][i].money, time+keiro[pos][i].time, min_time);
			min_time = (tmp==-1)? min_time : tmp;
		}
	}
	return min_time;
}

int main(int argc, char const *argv[])
{
	cin >> N >> C >> 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){
		keiro[S[i]][T[i]].money = Y[i];
		keiro[S[i]][T[i]].time = M[i];
	}

	cout << loop(1, C, 0, -1) << endl;

	return 0;
}
0