답안 #960516

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960516 2024-04-10T14:59:26 Z thinknoexit Security Guard (JOI23_guard) C++17
37 / 100
191 ms 21016 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200200;
int a[N];
struct A {
    int v, w;
    bool operator < (const A& o) const {
        if (w != o.w) return w > o.w;
        return a[v] > a[o.v];
    }
};
priority_queue<A> pq;
int dis[N];
bool vis[N];
vector<int> adj[N];
ll ans = 0;
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    memset(dis, 0x3f, sizeof dis);
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 1;i <= n;i++) {
        cin >> a[i];
    }
    while (m--) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int idx = max_element(a + 1, a + 1 + n) - a;
    dis[idx] = 0;
    pq.push({ idx, 0 });
    while (!pq.empty()) {
        auto x = pq.top();
        pq.pop();
        int v = x.v;
        if (vis[v]) continue;
        vis[v] = 1;
        ans += dis[v];
        for (auto& x : adj[v]) {
            if (!vis[x] && dis[x] > a[v]) {
                dis[x] = a[v];
                pq.push({ x, a[v] });
            }
        }
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 56 ms 15988 KB Output is correct
3 Correct 48 ms 16076 KB Output is correct
4 Correct 57 ms 16264 KB Output is correct
5 Correct 55 ms 15896 KB Output is correct
6 Correct 49 ms 15832 KB Output is correct
7 Correct 51 ms 15952 KB Output is correct
8 Correct 1 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 56 ms 15988 KB Output is correct
3 Correct 48 ms 16076 KB Output is correct
4 Correct 57 ms 16264 KB Output is correct
5 Correct 55 ms 15896 KB Output is correct
6 Correct 49 ms 15832 KB Output is correct
7 Correct 51 ms 15952 KB Output is correct
8 Correct 1 ms 6744 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 64 ms 17628 KB Output is correct
11 Correct 73 ms 17740 KB Output is correct
12 Correct 56 ms 17488 KB Output is correct
13 Correct 58 ms 17436 KB Output is correct
14 Correct 59 ms 17576 KB Output is correct
15 Correct 58 ms 17756 KB Output is correct
16 Correct 58 ms 17492 KB Output is correct
17 Correct 56 ms 17608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 56 ms 15988 KB Output is correct
3 Correct 48 ms 16076 KB Output is correct
4 Correct 57 ms 16264 KB Output is correct
5 Correct 55 ms 15896 KB Output is correct
6 Correct 49 ms 15832 KB Output is correct
7 Correct 51 ms 15952 KB Output is correct
8 Correct 1 ms 6744 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 64 ms 17628 KB Output is correct
11 Correct 73 ms 17740 KB Output is correct
12 Correct 56 ms 17488 KB Output is correct
13 Correct 58 ms 17436 KB Output is correct
14 Correct 59 ms 17576 KB Output is correct
15 Correct 58 ms 17756 KB Output is correct
16 Correct 58 ms 17492 KB Output is correct
17 Correct 56 ms 17608 KB Output is correct
18 Correct 2 ms 6744 KB Output is correct
19 Correct 98 ms 17604 KB Output is correct
20 Correct 137 ms 17500 KB Output is correct
21 Correct 92 ms 17488 KB Output is correct
22 Correct 113 ms 18260 KB Output is correct
23 Correct 108 ms 18608 KB Output is correct
24 Correct 117 ms 19508 KB Output is correct
25 Correct 138 ms 19624 KB Output is correct
26 Correct 131 ms 20276 KB Output is correct
27 Correct 134 ms 20336 KB Output is correct
28 Correct 109 ms 18408 KB Output is correct
29 Correct 99 ms 18400 KB Output is correct
30 Correct 151 ms 19416 KB Output is correct
31 Correct 128 ms 20548 KB Output is correct
32 Correct 137 ms 19364 KB Output is correct
33 Correct 77 ms 16608 KB Output is correct
34 Correct 106 ms 18748 KB Output is correct
35 Correct 102 ms 20680 KB Output is correct
36 Correct 105 ms 21016 KB Output is correct
37 Correct 154 ms 20964 KB Output is correct
38 Correct 114 ms 18216 KB Output is correct
39 Correct 110 ms 18936 KB Output is correct
40 Correct 110 ms 18312 KB Output is correct
41 Correct 100 ms 16884 KB Output is correct
42 Correct 108 ms 16940 KB Output is correct
43 Correct 191 ms 17888 KB Output is correct
44 Correct 124 ms 18048 KB Output is correct
45 Correct 109 ms 18036 KB Output is correct
46 Correct 120 ms 17896 KB Output is correct
47 Correct 143 ms 18128 KB Output is correct
48 Correct 115 ms 17744 KB Output is correct
49 Correct 108 ms 18164 KB Output is correct
50 Correct 107 ms 17744 KB Output is correct
51 Correct 112 ms 17948 KB Output is correct
52 Correct 88 ms 16212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 56 ms 15988 KB Output is correct
3 Correct 48 ms 16076 KB Output is correct
4 Correct 57 ms 16264 KB Output is correct
5 Correct 55 ms 15896 KB Output is correct
6 Correct 49 ms 15832 KB Output is correct
7 Correct 51 ms 15952 KB Output is correct
8 Correct 1 ms 6744 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 64 ms 17628 KB Output is correct
11 Correct 73 ms 17740 KB Output is correct
12 Correct 56 ms 17488 KB Output is correct
13 Correct 58 ms 17436 KB Output is correct
14 Correct 59 ms 17576 KB Output is correct
15 Correct 58 ms 17756 KB Output is correct
16 Correct 58 ms 17492 KB Output is correct
17 Correct 56 ms 17608 KB Output is correct
18 Correct 2 ms 6744 KB Output is correct
19 Correct 98 ms 17604 KB Output is correct
20 Correct 137 ms 17500 KB Output is correct
21 Correct 92 ms 17488 KB Output is correct
22 Correct 113 ms 18260 KB Output is correct
23 Correct 108 ms 18608 KB Output is correct
24 Correct 117 ms 19508 KB Output is correct
25 Correct 138 ms 19624 KB Output is correct
26 Correct 131 ms 20276 KB Output is correct
27 Correct 134 ms 20336 KB Output is correct
28 Correct 109 ms 18408 KB Output is correct
29 Correct 99 ms 18400 KB Output is correct
30 Correct 151 ms 19416 KB Output is correct
31 Correct 128 ms 20548 KB Output is correct
32 Correct 137 ms 19364 KB Output is correct
33 Correct 77 ms 16608 KB Output is correct
34 Correct 106 ms 18748 KB Output is correct
35 Correct 102 ms 20680 KB Output is correct
36 Correct 105 ms 21016 KB Output is correct
37 Correct 154 ms 20964 KB Output is correct
38 Correct 114 ms 18216 KB Output is correct
39 Correct 110 ms 18936 KB Output is correct
40 Correct 110 ms 18312 KB Output is correct
41 Correct 100 ms 16884 KB Output is correct
42 Correct 108 ms 16940 KB Output is correct
43 Correct 191 ms 17888 KB Output is correct
44 Correct 124 ms 18048 KB Output is correct
45 Correct 109 ms 18036 KB Output is correct
46 Correct 120 ms 17896 KB Output is correct
47 Correct 143 ms 18128 KB Output is correct
48 Correct 115 ms 17744 KB Output is correct
49 Correct 108 ms 18164 KB Output is correct
50 Correct 107 ms 17744 KB Output is correct
51 Correct 112 ms 17948 KB Output is correct
52 Correct 88 ms 16212 KB Output is correct
53 Correct 1 ms 6800 KB Output is correct
54 Incorrect 108 ms 17880 KB Output isn't correct
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 1 ms 6748 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 1 ms 6748 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 56 ms 15988 KB Output is correct
3 Correct 48 ms 16076 KB Output is correct
4 Correct 57 ms 16264 KB Output is correct
5 Correct 55 ms 15896 KB Output is correct
6 Correct 49 ms 15832 KB Output is correct
7 Correct 51 ms 15952 KB Output is correct
8 Correct 1 ms 6744 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 64 ms 17628 KB Output is correct
11 Correct 73 ms 17740 KB Output is correct
12 Correct 56 ms 17488 KB Output is correct
13 Correct 58 ms 17436 KB Output is correct
14 Correct 59 ms 17576 KB Output is correct
15 Correct 58 ms 17756 KB Output is correct
16 Correct 58 ms 17492 KB Output is correct
17 Correct 56 ms 17608 KB Output is correct
18 Correct 2 ms 6744 KB Output is correct
19 Correct 98 ms 17604 KB Output is correct
20 Correct 137 ms 17500 KB Output is correct
21 Correct 92 ms 17488 KB Output is correct
22 Correct 113 ms 18260 KB Output is correct
23 Correct 108 ms 18608 KB Output is correct
24 Correct 117 ms 19508 KB Output is correct
25 Correct 138 ms 19624 KB Output is correct
26 Correct 131 ms 20276 KB Output is correct
27 Correct 134 ms 20336 KB Output is correct
28 Correct 109 ms 18408 KB Output is correct
29 Correct 99 ms 18400 KB Output is correct
30 Correct 151 ms 19416 KB Output is correct
31 Correct 128 ms 20548 KB Output is correct
32 Correct 137 ms 19364 KB Output is correct
33 Correct 77 ms 16608 KB Output is correct
34 Correct 106 ms 18748 KB Output is correct
35 Correct 102 ms 20680 KB Output is correct
36 Correct 105 ms 21016 KB Output is correct
37 Correct 154 ms 20964 KB Output is correct
38 Correct 114 ms 18216 KB Output is correct
39 Correct 110 ms 18936 KB Output is correct
40 Correct 110 ms 18312 KB Output is correct
41 Correct 100 ms 16884 KB Output is correct
42 Correct 108 ms 16940 KB Output is correct
43 Correct 191 ms 17888 KB Output is correct
44 Correct 124 ms 18048 KB Output is correct
45 Correct 109 ms 18036 KB Output is correct
46 Correct 120 ms 17896 KB Output is correct
47 Correct 143 ms 18128 KB Output is correct
48 Correct 115 ms 17744 KB Output is correct
49 Correct 108 ms 18164 KB Output is correct
50 Correct 107 ms 17744 KB Output is correct
51 Correct 112 ms 17948 KB Output is correct
52 Correct 88 ms 16212 KB Output is correct
53 Correct 1 ms 6800 KB Output is correct
54 Incorrect 108 ms 17880 KB Output isn't correct
55 Halted 0 ms 0 KB -