結果

問題 No.1449 新プロランド
ユーザー googol_S0googol_S0
提出日時 2021-03-31 15:13:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,152 bytes
コンパイル時間 2,238 ms
コンパイル使用メモリ 208,704 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-25 16:48:14
合計ジャッジ時間 3,464 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int>>> G(102,vector<pair<int,int>>(0));
vector<int> D(101234);
int INF=10000000;
int N;
vector<int> T(102);
void ijk(int s){
  for(int i=0;i<(int)(D.size());i++){
    D[i]=INF;
  }
  D[s]=0;
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;
  Q.push(make_pair(0,s));
  int v,x,y,a,b;
  pair<int,int> p;
  while(!Q.empty()){
    p=Q.top();
    Q.pop();
    v=p.second;
    x=v/N;
    y=v-x*N;
    if(D[v]<p.first){
      continue;
    }
    for(int i=0;i<(int)(G[y].size());i++){
      a=G[y][i].first;
      b=G[y][i].second/x;
      if(D[min(1001,T[a]+x)*N+a]>D[v]+T[a]+b){
        D[min(1001,T[a]+x)*N+a]=D[v]+T[a]+b;
        Q.push(make_pair(D[min(1001,T[a]+x)*N+a],min(1001,T[a]+x)*N+a));
      }
    }
  }
}
int main(){
  int M;
  cin>>N>>M;
  int a,b,c;
  for(int i=0;i<M;i++){
    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];
  }
  ijk(T[0]*N);
  int ANS=INF;
  for(int i=0;i<=1000;i++){
    ANS=min(ANS,D[(i+1)*N-1]+T[0]);
  }
  cout<<ANS<<"\n";
}
0