結果

問題 No.1449 新プロランド
ユーザー 👑 NachiaNachia
提出日時 2021-03-31 15:47:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,116 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 209,780 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 16:49:28
合計ジャッジ時間 3,488 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 10 ms
4,384 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 10 ms
4,380 KB
testcase_09 AC 7 ms
4,380 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 7 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 4 ms
4,384 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 6 ms
4,380 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 16 ms
4,384 KB
testcase_28 AC 10 ms
4,380 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][1001];
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,1001) 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];
    c = min(c,1000);
    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,1001){
    if(D[N-1][i]!=-1) ans=min(ans,D[N-1][i]);
  }
  cout<<ans<<"\n";
  return 0;
}
0