結果

問題 No.2387 Yokan Factory
ユーザー kotatsugamekotatsugame
提出日時 2023-07-21 21:30:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 342 ms / 5,000 ms
コード長 922 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 79,964 KB
実行使用メモリ 11,552 KB
最終ジャッジ日時 2023-10-21 21:20:14
合計ジャッジ時間 4,486 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,976 KB
testcase_01 AC 4 ms
6,976 KB
testcase_02 AC 3 ms
7,024 KB
testcase_03 AC 4 ms
6,980 KB
testcase_04 AC 3 ms
6,980 KB
testcase_05 AC 4 ms
7,028 KB
testcase_06 AC 3 ms
6,980 KB
testcase_07 AC 4 ms
6,980 KB
testcase_08 AC 4 ms
6,980 KB
testcase_09 AC 4 ms
6,980 KB
testcase_10 AC 3 ms
7,024 KB
testcase_11 AC 3 ms
6,976 KB
testcase_12 AC 4 ms
6,976 KB
testcase_13 AC 4 ms
7,024 KB
testcase_14 AC 3 ms
6,976 KB
testcase_15 AC 154 ms
11,524 KB
testcase_16 AC 101 ms
11,152 KB
testcase_17 AC 269 ms
11,552 KB
testcase_18 AC 342 ms
10,832 KB
testcase_19 AC 140 ms
9,912 KB
testcase_20 AC 72 ms
9,548 KB
testcase_21 AC 319 ms
10,656 KB
testcase_22 AC 84 ms
9,420 KB
testcase_23 AC 278 ms
9,756 KB
testcase_24 AC 91 ms
9,468 KB
testcase_25 AC 92 ms
8,728 KB
testcase_26 AC 168 ms
10,116 KB
testcase_27 AC 93 ms
10,388 KB
testcase_28 AC 4 ms
7,088 KB
testcase_29 AC 5 ms
7,116 KB
testcase_30 AC 5 ms
7,116 KB
testcase_31 AC 5 ms
7,084 KB
testcase_32 AC 4 ms
7,060 KB
testcase_33 AC 4 ms
7,056 KB
testcase_34 AC 6 ms
7,128 KB
testcase_35 AC 5 ms
7,108 KB
testcase_36 AC 4 ms
7,056 KB
testcase_37 AC 3 ms
7,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>
#include<cassert>
using namespace std;
int N,M;
long X;
vector<pair<int,pair<int,int> > >G[1<<17];
long D[1<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>M>>X;
	for(int i=0;i<M;i++)
	{
		int u,v,a,b;
		cin>>u>>v>>a>>b;
		u--,v--;
		G[u].push_back(make_pair(v,make_pair(a,b)));
		G[v].push_back(make_pair(u,make_pair(a,b)));
	}
	int L=0,R=(int)1e9+1;
	while(R-L>1)
	{
		int mid=(L+R)/2;
		for(int i=1;i<N;i++)D[i]=X+1;
		priority_queue<pair<long,int> >Q;
		Q.push(make_pair(0,0));
		while(!Q.empty())
		{
			int u=Q.top().second;
			long d=-Q.top().first;
			Q.pop();
			if(D[u]<d)continue;
			for(pair<int,pair<int,int> >e:G[u])if(e.second.second>=mid)
			{
				int v=e.first;
				long nd=d+e.second.first;
				if(D[v]>nd)
				{
					D[v]=nd;
					Q.push(make_pair(-nd,v));
				}
			}
		}
		if(D[N-1]<=X)L=mid;
		else R=mid;
	}
	cout<<(L==0?-1:L)<<endl;
}
0