結果

問題 No.1449 新プロランド
ユーザー 👑 NachiaNachia
提出日時 2021-03-31 14:30:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 209,584 KB
実行使用メモリ 7,064 KB
最終ジャッジ日時 2023-08-25 16:45:26
合計ジャッジ時間 4,164 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 9 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 129 ms
7,008 KB
testcase_06 AC 69 ms
5,740 KB
testcase_07 AC 36 ms
5,676 KB
testcase_08 AC 83 ms
7,064 KB
testcase_09 AC 30 ms
4,380 KB
testcase_10 AC 36 ms
6,392 KB
testcase_11 AC 11 ms
6,976 KB
testcase_12 AC 83 ms
6,444 KB
testcase_13 AC 36 ms
4,708 KB
testcase_14 AC 12 ms
6,852 KB
testcase_15 AC 82 ms
6,044 KB
testcase_16 AC 51 ms
4,832 KB
testcase_17 AC 60 ms
5,520 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 4 ms
5,916 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 22 ms
5,740 KB
testcase_22 AC 9 ms
4,380 KB
testcase_23 AC 27 ms
6,708 KB
testcase_24 AC 24 ms
4,376 KB
testcase_25 AC 13 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 121 ms
6,980 KB
testcase_28 AC 52 ms
4,688 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][10001];
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,10001) 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>10000) 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,10001){
    if(D[N-1][i]!=-1) ans=min(ans,D[N-1][i]);
  }
  cout<<ans<<"\n";
  return 0;
}
0