結果

問題 No.1449 新プロランド
ユーザー 沙耶花沙耶花
提出日時 2021-03-31 14:24:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,143 bytes
コンパイル時間 5,846 ms
コンパイル使用メモリ 267,996 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 16:45:18
合計ジャッジ時間 5,503 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 5 ms
4,384 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 5 ms
4,380 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 13 ms
4,380 KB
testcase_28 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<pair<int,int>>> E(N);
	rep(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		E[a].emplace_back(b,c);
		E[b].emplace_back(a,c);
	}
	
	vector<int> T(N);
	rep(i,N)cin>>T[i];
	
	vector<vector<int>> dis(N,vector<int>(1001,Inf));
	priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> Q;
	Q.emplace(T[0],make_pair(0,T[0]));
	dis[0][T[0]] = T[0];
	
	while(Q.size()>0){
		int D = Q.top().first;
		int u = Q.top().second.first;
		int t = Q.top().second.second;
		Q.pop();
		if(dis[u][t]!=D)continue;
		
		rep(i,E[u].size()){
			int v = E[u][i].first;
			int c = E[u][i].second;
			int D2 = T[v] + c/t;
			int nt = min(1000,t + T[v]);
			
			if(dis[v][nt]>D+D2){
				dis[v][nt] = D+D2;
				Q.emplace(D+D2,make_pair(v,nt));
			}
		}
		
	}
	
	int ans = Inf;
	rep(i,1001)ans = min(ans,dis.back()[i]);
	
	cout<<ans<<endl;
	
    return 0;
}
0