結果

問題 No.1 道のショートカット
ユーザー kotatsugamekotatsugame
提出日時 2016-11-05 00:35:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 816 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 76,008 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-22 12:51:03
合計ジャッジ時間 10,829 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3,065 ms
4,380 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,504 KB
testcase_23 TLE -
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;

const int INF=1<<21;

class road
{
public:
	int y;
	int m;
};

int n,c,m;
vector<vector<pair<int,road>>> v;

int solve(int nowc,int now)
{
	if(nowc<0)return INF;
	if(now==n-1)return 0;
	int ans=INF;
	for(int i=0;i<v[now].size();i++)
	{
		ans=min(ans,v[now][i].second.m+solve(nowc-v[now][i].second.y,v[now][i].first));
	}
	return ans;
}

int main()
{
	cin>>n>>c>>m;
	v.resize(n);road r;
	int ss[1500],tt[1500],yy[1500],mm[1500];
	for(int i=0;i<m;i++){cin>>ss[i];ss[i]--;}
	for(int i=0;i<m;i++){cin>>tt[i];tt[i]--;}
	for(int i=0;i<m;i++)cin>>yy[i];
	for(int i=0;i<m;i++)cin>>mm[i];
	for(int i=0;i<m;i++)
	{
		r.y=yy[i];r.m=mm[i];
		v[ss[i]].push_back(make_pair(tt[i],r));
	}
	int ans=solve(c,0);
	cout<<(ans==INF?-1:ans)<<endl;
	return 0;
}
0