# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1055712 |
2024-08-13T04:16:56 Z |
변재우(#11070) |
Treasure Hunt (CCO24_day1problem1) |
C++17 |
|
101 ms |
141240 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Nmax=1000010, INF=1e18;
int N, M, A[Nmax], D[2*Nmax];
vector<pair<int, int>> adj[Nmax];
priority_queue<pair<int, int>> PQ;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>N>>M;
for(int i=1; i<=N; i++) cin>>A[i], adj[N+i].push_back({i, -A[i]});
for(int i=1; i<=M; i++) {
int u, v, w; cin>>u>>v>>w;
adj[u].push_back({v, w}), adj[v].push_back({u, w});
}
fill(D+1, D+N+1, INF);
for(int i=N+1; i<=2*N; i++) PQ.push({0, i});
while(!PQ.empty()) {
int curr=PQ.top().second, dist=-PQ.top().first; PQ.pop();
if(D[curr]!=dist) continue;
for(auto [next, w]:adj[curr]) if(D[next]>D[curr]+w) D[next]=D[curr]+w, PQ.push({-D[next], next});
}
for(int i=1; i<=N; i++) cout<<-D[i]<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
27736 KB |
Output is correct |
2 |
Correct |
5 ms |
27740 KB |
Output is correct |
3 |
Correct |
5 ms |
27740 KB |
Output is correct |
4 |
Correct |
6 ms |
27740 KB |
Output is correct |
5 |
Correct |
4 ms |
27228 KB |
Output is correct |
6 |
Correct |
3 ms |
27228 KB |
Output is correct |
7 |
Correct |
3 ms |
27228 KB |
Output is correct |
8 |
Correct |
5 ms |
27740 KB |
Output is correct |
9 |
Correct |
7 ms |
27740 KB |
Output is correct |
10 |
Correct |
6 ms |
27740 KB |
Output is correct |
11 |
Correct |
4 ms |
27480 KB |
Output is correct |
12 |
Correct |
4 ms |
27484 KB |
Output is correct |
13 |
Correct |
3 ms |
27228 KB |
Output is correct |
14 |
Correct |
3 ms |
27316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
101 ms |
141240 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
99 ms |
134736 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
27736 KB |
Output is correct |
2 |
Correct |
5 ms |
27740 KB |
Output is correct |
3 |
Correct |
5 ms |
27740 KB |
Output is correct |
4 |
Correct |
6 ms |
27740 KB |
Output is correct |
5 |
Correct |
4 ms |
27228 KB |
Output is correct |
6 |
Correct |
3 ms |
27228 KB |
Output is correct |
7 |
Correct |
3 ms |
27228 KB |
Output is correct |
8 |
Correct |
5 ms |
27740 KB |
Output is correct |
9 |
Correct |
7 ms |
27740 KB |
Output is correct |
10 |
Correct |
6 ms |
27740 KB |
Output is correct |
11 |
Correct |
4 ms |
27480 KB |
Output is correct |
12 |
Correct |
4 ms |
27484 KB |
Output is correct |
13 |
Correct |
3 ms |
27228 KB |
Output is correct |
14 |
Correct |
3 ms |
27316 KB |
Output is correct |
15 |
Runtime error |
101 ms |
141240 KB |
Execution killed with signal 11 |
16 |
Halted |
0 ms |
0 KB |
- |