結果

問題 No.1449 新プロランド
ユーザー yansi819yansi819
提出日時 2024-04-29 16:26:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,343 bytes
コンパイル時間 4,705 ms
コンパイル使用メモリ 274,040 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 16:26:13
合計ジャッジ時間 5,810 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> g(N);
  map<pair<int, int>, int> edge;
  for (int i = 0; i < M; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
    edge[make_pair(a, b)] = c;
  }
  vector<int> t(N);
  for (int i = 0; i < N; i++) cin >> t[i];
  vector<ll> dist(N, 1e18);
  dist[0] = t[0];
  vector<ll> cost(N, 0);
  cost[0] = t[0];
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
  pq.push(make_pair(t[0], 0));
  //vector<bool> vis(N, false);
  //vis[0] = true;
  while (!pq.empty()) {
    auto [d, u] = pq.top(); pq.pop();
    for (auto v: g[u]) {
      //if (vis[v]) continue;
      if (dist[v] > dist[u] + t[v] + edge[make_pair(min(u, v), max(u, v))] / cost[u]) {
        cost[v] = cost[u] + t[v];
        dist[v] = dist[u] + t[v] + edge[make_pair(min(u, v), max(u, v))] / cost[u];
        //vis[v] = true;
        pq.push(make_pair(dist[v], v));
      }
    }
  }
  //for (int i = 0; i < N; i++) cout << cost[i] << " \n"[i == N - 1];
  //for (int i = 0; i < N; i++) cout << dist[i] << " \n"[i == N - 1];
  cout << dist[N - 1] << endl;
  return 0;
}
0