結果

問題 No.1449 新プロランド
ユーザー kotatsugamekotatsugame
提出日時 2021-03-31 15:27:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 80,892 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 16:48:36
合計ジャッジ時間 2,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 10 ms
4,380 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 7 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 8 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 6 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 15 ms
4,376 KB
testcase_28 AC 10 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int N,M;
vector<pair<int,int> >G[100];
int T[100];
int dist[100][1002];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		a--,b--;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	for(int i=0;i<N;i++)
	{
		cin>>T[i];
		for(int j=0;j<=1001;j++)dist[i][j]=1e9;
	}
	dist[0][0]=0;
	priority_queue<pair<int,pair<int,int> > >P;
	P.push(make_pair(0,make_pair(0,0)));
	while(!P.empty())
	{
		int u=P.top().second.first;
		int t=P.top().second.second;
		int cost=-P.top().first;
		P.pop();
		if(dist[u][t]<cost)continue;
		int nt=t+T[u];
		if(nt>=1001)nt=1001;
		for(pair<int,int>e:G[u])
		{
			int v=e.first;
			int nxt=cost+e.second/nt+T[u];
			if(dist[v][nt]>nxt)
			{
				dist[v][nt]=nxt;
				P.push(make_pair(-nxt,make_pair(v,nt)));
			}
		}
	}
	int ans=1e9;
	for(int j=0;j<=1001;j++)ans=min(ans,dist[N-1][j]);
	cout<<ans<<endl;
}
0