답안 #1055714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055714 2024-08-13T04:20:16 Z 변재우(#11070) Treasure Hunt (CCO24_day1problem1) C++17
25 / 25
939 ms 151528 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int Nmax=1000010, INF=1e18;
int N, M, mx, A[Nmax], D[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], mx=max(mx, 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});
    }
    for(int i=1; i<=N; i++) D[i]=mx-A[i], PQ.push({-D[i], 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]+mx<<"\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 27484 KB Output is correct
2 Correct 5 ms 27484 KB Output is correct
3 Correct 4 ms 27484 KB Output is correct
4 Correct 5 ms 27532 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 6 ms 27544 KB Output is correct
9 Correct 6 ms 27484 KB Output is correct
10 Correct 5 ms 27484 KB Output is correct
11 Correct 4 ms 27484 KB Output is correct
12 Correct 4 ms 27484 KB Output is correct
13 Correct 3 ms 27320 KB Output is correct
14 Correct 5 ms 27256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 939 ms 116336 KB Output is correct
2 Correct 806 ms 118980 KB Output is correct
3 Correct 891 ms 116228 KB Output is correct
4 Correct 820 ms 118928 KB Output is correct
5 Correct 800 ms 118032 KB Output is correct
6 Correct 825 ms 116140 KB Output is correct
7 Correct 777 ms 115872 KB Output is correct
8 Correct 798 ms 115368 KB Output is correct
9 Correct 732 ms 112648 KB Output is correct
10 Correct 769 ms 109984 KB Output is correct
11 Correct 665 ms 106928 KB Output is correct
12 Correct 694 ms 106408 KB Output is correct
13 Correct 586 ms 104116 KB Output is correct
14 Correct 603 ms 103612 KB Output is correct
15 Correct 274 ms 84824 KB Output is correct
16 Correct 251 ms 84764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 824 ms 118952 KB Output is correct
2 Correct 908 ms 116396 KB Output is correct
3 Correct 840 ms 119032 KB Output is correct
4 Correct 829 ms 119036 KB Output is correct
5 Correct 3 ms 27228 KB Output is correct
6 Correct 3 ms 27228 KB Output is correct
7 Correct 924 ms 119420 KB Output is correct
8 Correct 864 ms 119200 KB Output is correct
9 Correct 822 ms 118952 KB Output is correct
10 Correct 852 ms 118952 KB Output is correct
11 Correct 3 ms 27228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 27484 KB Output is correct
2 Correct 5 ms 27484 KB Output is correct
3 Correct 4 ms 27484 KB Output is correct
4 Correct 5 ms 27532 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 6 ms 27544 KB Output is correct
9 Correct 6 ms 27484 KB Output is correct
10 Correct 5 ms 27484 KB Output is correct
11 Correct 4 ms 27484 KB Output is correct
12 Correct 4 ms 27484 KB Output is correct
13 Correct 3 ms 27320 KB Output is correct
14 Correct 5 ms 27256 KB Output is correct
15 Correct 939 ms 116336 KB Output is correct
16 Correct 806 ms 118980 KB Output is correct
17 Correct 891 ms 116228 KB Output is correct
18 Correct 820 ms 118928 KB Output is correct
19 Correct 800 ms 118032 KB Output is correct
20 Correct 825 ms 116140 KB Output is correct
21 Correct 777 ms 115872 KB Output is correct
22 Correct 798 ms 115368 KB Output is correct
23 Correct 732 ms 112648 KB Output is correct
24 Correct 769 ms 109984 KB Output is correct
25 Correct 665 ms 106928 KB Output is correct
26 Correct 694 ms 106408 KB Output is correct
27 Correct 586 ms 104116 KB Output is correct
28 Correct 603 ms 103612 KB Output is correct
29 Correct 274 ms 84824 KB Output is correct
30 Correct 251 ms 84764 KB Output is correct
31 Correct 824 ms 118952 KB Output is correct
32 Correct 908 ms 116396 KB Output is correct
33 Correct 840 ms 119032 KB Output is correct
34 Correct 829 ms 119036 KB Output is correct
35 Correct 3 ms 27228 KB Output is correct
36 Correct 3 ms 27228 KB Output is correct
37 Correct 924 ms 119420 KB Output is correct
38 Correct 864 ms 119200 KB Output is correct
39 Correct 822 ms 118952 KB Output is correct
40 Correct 852 ms 118952 KB Output is correct
41 Correct 3 ms 27228 KB Output is correct
42 Correct 915 ms 129836 KB Output is correct
43 Correct 832 ms 151528 KB Output is correct
44 Correct 840 ms 136612 KB Output is correct
45 Correct 847 ms 144760 KB Output is correct
46 Correct 934 ms 135076 KB Output is correct
47 Correct 936 ms 127076 KB Output is correct
48 Correct 920 ms 140412 KB Output is correct
49 Correct 803 ms 125184 KB Output is correct
50 Correct 864 ms 129180 KB Output is correct
51 Correct 294 ms 98204 KB Output is correct
52 Correct 293 ms 89424 KB Output is correct
53 Correct 181 ms 74336 KB Output is correct
54 Correct 148 ms 77396 KB Output is correct
55 Correct 867 ms 139432 KB Output is correct
56 Correct 855 ms 121596 KB Output is correct
57 Correct 327 ms 107684 KB Output is correct