結果

問題 No.1449 新プロランド
ユーザー 👑 NachiaNachia
提出日時 2021-03-31 14:39:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,259 ms / 2,000 ms
コード長 1,129 bytes
コンパイル時間 3,086 ms
コンパイル使用メモリ 210,800 KB
実行使用メモリ 40,412 KB
最終ジャッジ日時 2023-08-25 16:45:50
合計ジャッジ時間 12,507 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,376 KB
testcase_01 AC 13 ms
4,956 KB
testcase_02 AC 68 ms
7,568 KB
testcase_03 AC 4 ms
4,904 KB
testcase_04 AC 7 ms
4,892 KB
testcase_05 AC 1,259 ms
38,580 KB
testcase_06 AC 643 ms
25,984 KB
testcase_07 AC 341 ms
27,936 KB
testcase_08 AC 798 ms
40,412 KB
testcase_09 AC 262 ms
11,612 KB
testcase_10 AC 321 ms
34,276 KB
testcase_11 AC 67 ms
38,196 KB
testcase_12 AC 815 ms
34,480 KB
testcase_13 AC 322 ms
15,700 KB
testcase_14 AC 89 ms
38,192 KB
testcase_15 AC 785 ms
30,144 KB
testcase_16 AC 490 ms
17,744 KB
testcase_17 AC 569 ms
25,988 KB
testcase_18 AC 3 ms
4,544 KB
testcase_19 AC 9 ms
30,016 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 189 ms
28,012 KB
testcase_22 AC 65 ms
7,480 KB
testcase_23 AC 243 ms
36,148 KB
testcase_24 AC 204 ms
9,536 KB
testcase_25 AC 134 ms
9,560 KB
testcase_26 AC 9 ms
4,664 KB
testcase_27 AC 1,167 ms
38,328 KB
testcase_28 AC 474 ms
15,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

struct Edge{ int to; int d; };
using dijkstra_queue = priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>>;

int N,M;
vector<vector<Edge>> E;
int D[100][100001];
int C[100];

int main(){
  cin>>N>>M;
  E.resize(N);
  rep(i,M){
    int u,v,c; cin>>u>>v>>c; u--; v--;
    E[u].push_back({v,c});
    E[v].push_back({u,c}); 
  }
  rep(i,N) cin>>C[i];
  rep(i,N) rep(d,100001) D[i][d]=-1;

  dijkstra_queue Q;
  D[0][0]=0; Q.push({0,{0,0}});
  while(Q.size()){
    int p=Q.top().second.first;
    int c=Q.top().second.second;
    int t=Q.top().first;
    Q.pop();
    if(D[p][c]!=t) continue;
    c += C[p]; t += C[p];
    if(c>100000) continue;
    for(Edge e:E[p]){
      int nxt = t + e.d / c;
      if(D[e.to][c] != -1 && D[e.to][c] <= nxt) continue;
      D[e.to][c] = nxt;
      Q.push({nxt,{e.to,c}});
    }
  }

  int ans=1001001001;
  rep(i,100001){
    if(D[N-1][i]!=-1) ans=min(ans,D[N-1][i]);
  }
  cout<<ans<<"\n";
  return 0;
}
0