結果

問題 No.1 道のショートカット
ユーザー ynq1242ynq1242
提出日時 2014-10-26 13:53:03
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,983 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 88,056 KB
実行使用メモリ 7,760 KB
最終ジャッジ日時 2023-09-22 11:44:50
合計ジャッジ時間 7,721 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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 <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
#include<ctime>
#include<set>
using namespace std;


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

vector<string> split(const string &str, char delim){
  istringstream iss(str); string tmp; vector<string> res;
  while(getline(iss, tmp, delim)) res.push_back(tmp);
  return res;
}

li sstoi(string s){
	return atoi(s.c_str());
}

li n,c,v;
vector<pair<li, pair<li,li> > > edge[60];

li s[1515], t[1515], y[1515], m[1515];

li dfs(li from, li to, li total_cost, li total_time){
	li res=1000000000000;
	rep(i,sz(edge[from])){
		li next=edge[from][i].F;
		li cost=edge[from][i].S.F;
		li minutes=edge[from][i].S.S;
		if(next==to){
			if(total_cost+cost<=c)res=min(res, total_time+minutes);
		}
		else{
			li result=dfs(next, to, total_cost+cost, total_time+minutes);
			if(result>=0)res=min(res, result);
		}
	}
	return (res>100000000000 ? -1 : res);
}

int main(){
	cin>>n>>c>>v;
	rep(i,v)cin>>s[i];
	rep(i,v)cin>>t[i];
	rep(i,v)cin>>y[i];
	rep(i,v)cin>>m[i];

	rep(i,v){
		edge[s[i]-1].pb(mp(t[i]-1, mp(y[i], m[i])));
	}

	cout<<dfs(0, n-1, 0, 0)<<endl;

	return 0;
}
0