Submission #929259

#TimeUsernameProblemLanguageResultExecution timeMemory
929259dubabubaAirplane (NOI23_airplane)C++14
0 / 100
131 ms38984 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; #define ff first #define ss second #define MP make_pair const int mxn = 1e6 + 10; int dis[mxn], a[mxn], n, m; vector<int> adj[mxn]; int main() { cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 0; i < m; i++) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } memset(dis, -1, sizeof dis); priority_queue<pii> pq; pq.push(MP(0, 1)); while(pq.size()) { int d = -pq.top().ff; int u = pq.top().ss; pq.pop(); if(dis[u] > -1) continue; dis[u] = d; for(int v : adj[u]) if(dis[v] == -1) pq.push(MP(-max(d, a[v]), v)); } cout << dis[n] * 2 << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...