Submission #960293

# Submission time Handle Problem Language Result Execution time Memory
960293 2024-04-10T07:42:15 Z thinknoexit Security Guard (JOI23_guard) C++17
37 / 100
128 ms 23412 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200200;
int a[N];
vector<int> adj[N];
ll ans = 0;
void dfs(int v, int p = -1) {
    for (auto& x : adj[v]) {
        if (x == p) continue;
        ans += a[v];
        dfs(x, v);
    }
}
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    if (m != n - 1) return 0;
    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;
    dfs(idx);
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 51 ms 21248 KB Output is correct
3 Correct 52 ms 21580 KB Output is correct
4 Correct 51 ms 21536 KB Output is correct
5 Correct 57 ms 21560 KB Output is correct
6 Correct 51 ms 21584 KB Output is correct
7 Correct 53 ms 21492 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 51 ms 21248 KB Output is correct
3 Correct 52 ms 21580 KB Output is correct
4 Correct 51 ms 21536 KB Output is correct
5 Correct 57 ms 21560 KB Output is correct
6 Correct 51 ms 21584 KB Output is correct
7 Correct 53 ms 21492 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 57 ms 20700 KB Output is correct
11 Correct 60 ms 23228 KB Output is correct
12 Correct 62 ms 23412 KB Output is correct
13 Correct 58 ms 23124 KB Output is correct
14 Correct 59 ms 23092 KB Output is correct
15 Correct 58 ms 23136 KB Output is correct
16 Correct 58 ms 22192 KB Output is correct
17 Correct 57 ms 22660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 51 ms 21248 KB Output is correct
3 Correct 52 ms 21580 KB Output is correct
4 Correct 51 ms 21536 KB Output is correct
5 Correct 57 ms 21560 KB Output is correct
6 Correct 51 ms 21584 KB Output is correct
7 Correct 53 ms 21492 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 57 ms 20700 KB Output is correct
11 Correct 60 ms 23228 KB Output is correct
12 Correct 62 ms 23412 KB Output is correct
13 Correct 58 ms 23124 KB Output is correct
14 Correct 59 ms 23092 KB Output is correct
15 Correct 58 ms 23136 KB Output is correct
16 Correct 58 ms 22192 KB Output is correct
17 Correct 57 ms 22660 KB Output is correct
18 Correct 1 ms 5152 KB Output is correct
19 Correct 128 ms 19736 KB Output is correct
20 Correct 87 ms 19372 KB Output is correct
21 Correct 77 ms 16480 KB Output is correct
22 Correct 71 ms 16724 KB Output is correct
23 Correct 73 ms 17488 KB Output is correct
24 Correct 66 ms 17524 KB Output is correct
25 Correct 60 ms 17472 KB Output is correct
26 Correct 56 ms 17332 KB Output is correct
27 Correct 72 ms 17400 KB Output is correct
28 Correct 83 ms 22100 KB Output is correct
29 Correct 86 ms 19164 KB Output is correct
30 Correct 63 ms 18244 KB Output is correct
31 Correct 57 ms 17348 KB Output is correct
32 Correct 81 ms 17104 KB Output is correct
33 Correct 70 ms 15948 KB Output is correct
34 Correct 70 ms 16676 KB Output is correct
35 Correct 82 ms 17728 KB Output is correct
36 Correct 68 ms 17712 KB Output is correct
37 Correct 67 ms 17900 KB Output is correct
38 Correct 75 ms 18896 KB Output is correct
39 Correct 78 ms 19980 KB Output is correct
40 Correct 73 ms 18080 KB Output is correct
41 Correct 126 ms 22612 KB Output is correct
42 Correct 97 ms 22612 KB Output is correct
43 Correct 105 ms 16720 KB Output is correct
44 Correct 73 ms 16720 KB Output is correct
45 Correct 90 ms 16992 KB Output is correct
46 Correct 82 ms 16908 KB Output is correct
47 Correct 78 ms 16780 KB Output is correct
48 Correct 72 ms 16832 KB Output is correct
49 Correct 94 ms 16620 KB Output is correct
50 Correct 72 ms 16720 KB Output is correct
51 Correct 73 ms 16968 KB Output is correct
52 Correct 70 ms 15304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 51 ms 21248 KB Output is correct
3 Correct 52 ms 21580 KB Output is correct
4 Correct 51 ms 21536 KB Output is correct
5 Correct 57 ms 21560 KB Output is correct
6 Correct 51 ms 21584 KB Output is correct
7 Correct 53 ms 21492 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 57 ms 20700 KB Output is correct
11 Correct 60 ms 23228 KB Output is correct
12 Correct 62 ms 23412 KB Output is correct
13 Correct 58 ms 23124 KB Output is correct
14 Correct 59 ms 23092 KB Output is correct
15 Correct 58 ms 23136 KB Output is correct
16 Correct 58 ms 22192 KB Output is correct
17 Correct 57 ms 22660 KB Output is correct
18 Correct 1 ms 5152 KB Output is correct
19 Correct 128 ms 19736 KB Output is correct
20 Correct 87 ms 19372 KB Output is correct
21 Correct 77 ms 16480 KB Output is correct
22 Correct 71 ms 16724 KB Output is correct
23 Correct 73 ms 17488 KB Output is correct
24 Correct 66 ms 17524 KB Output is correct
25 Correct 60 ms 17472 KB Output is correct
26 Correct 56 ms 17332 KB Output is correct
27 Correct 72 ms 17400 KB Output is correct
28 Correct 83 ms 22100 KB Output is correct
29 Correct 86 ms 19164 KB Output is correct
30 Correct 63 ms 18244 KB Output is correct
31 Correct 57 ms 17348 KB Output is correct
32 Correct 81 ms 17104 KB Output is correct
33 Correct 70 ms 15948 KB Output is correct
34 Correct 70 ms 16676 KB Output is correct
35 Correct 82 ms 17728 KB Output is correct
36 Correct 68 ms 17712 KB Output is correct
37 Correct 67 ms 17900 KB Output is correct
38 Correct 75 ms 18896 KB Output is correct
39 Correct 78 ms 19980 KB Output is correct
40 Correct 73 ms 18080 KB Output is correct
41 Correct 126 ms 22612 KB Output is correct
42 Correct 97 ms 22612 KB Output is correct
43 Correct 105 ms 16720 KB Output is correct
44 Correct 73 ms 16720 KB Output is correct
45 Correct 90 ms 16992 KB Output is correct
46 Correct 82 ms 16908 KB Output is correct
47 Correct 78 ms 16780 KB Output is correct
48 Correct 72 ms 16832 KB Output is correct
49 Correct 94 ms 16620 KB Output is correct
50 Correct 72 ms 16720 KB Output is correct
51 Correct 73 ms 16968 KB Output is correct
52 Correct 70 ms 15304 KB Output is correct
53 Incorrect 1 ms 4956 KB Output isn't correct
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Incorrect 1 ms 4952 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Incorrect 1 ms 4952 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 51 ms 21248 KB Output is correct
3 Correct 52 ms 21580 KB Output is correct
4 Correct 51 ms 21536 KB Output is correct
5 Correct 57 ms 21560 KB Output is correct
6 Correct 51 ms 21584 KB Output is correct
7 Correct 53 ms 21492 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 57 ms 20700 KB Output is correct
11 Correct 60 ms 23228 KB Output is correct
12 Correct 62 ms 23412 KB Output is correct
13 Correct 58 ms 23124 KB Output is correct
14 Correct 59 ms 23092 KB Output is correct
15 Correct 58 ms 23136 KB Output is correct
16 Correct 58 ms 22192 KB Output is correct
17 Correct 57 ms 22660 KB Output is correct
18 Correct 1 ms 5152 KB Output is correct
19 Correct 128 ms 19736 KB Output is correct
20 Correct 87 ms 19372 KB Output is correct
21 Correct 77 ms 16480 KB Output is correct
22 Correct 71 ms 16724 KB Output is correct
23 Correct 73 ms 17488 KB Output is correct
24 Correct 66 ms 17524 KB Output is correct
25 Correct 60 ms 17472 KB Output is correct
26 Correct 56 ms 17332 KB Output is correct
27 Correct 72 ms 17400 KB Output is correct
28 Correct 83 ms 22100 KB Output is correct
29 Correct 86 ms 19164 KB Output is correct
30 Correct 63 ms 18244 KB Output is correct
31 Correct 57 ms 17348 KB Output is correct
32 Correct 81 ms 17104 KB Output is correct
33 Correct 70 ms 15948 KB Output is correct
34 Correct 70 ms 16676 KB Output is correct
35 Correct 82 ms 17728 KB Output is correct
36 Correct 68 ms 17712 KB Output is correct
37 Correct 67 ms 17900 KB Output is correct
38 Correct 75 ms 18896 KB Output is correct
39 Correct 78 ms 19980 KB Output is correct
40 Correct 73 ms 18080 KB Output is correct
41 Correct 126 ms 22612 KB Output is correct
42 Correct 97 ms 22612 KB Output is correct
43 Correct 105 ms 16720 KB Output is correct
44 Correct 73 ms 16720 KB Output is correct
45 Correct 90 ms 16992 KB Output is correct
46 Correct 82 ms 16908 KB Output is correct
47 Correct 78 ms 16780 KB Output is correct
48 Correct 72 ms 16832 KB Output is correct
49 Correct 94 ms 16620 KB Output is correct
50 Correct 72 ms 16720 KB Output is correct
51 Correct 73 ms 16968 KB Output is correct
52 Correct 70 ms 15304 KB Output is correct
53 Incorrect 1 ms 4956 KB Output isn't correct
54 Halted 0 ms 0 KB -