# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
796046 | 2023-07-28T05:23:50 Z | 박상훈(#10069) | Security Guard (JOI23_guard) | C++17 | 151 ms | 18340 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> adj[200200]; int a[200200]; ll ans; void dfs(int s, int pa){ ans += a[pa]; for (auto &v:adj[s]) if (v!=pa) dfs(v, s); } int main(){ int n, m, q; scanf("%d %d %d", &n, &m, &q); for (int i=1;i<=n;i++) scanf("%d", a+i); int root = max_element(a+1, a+n+1) - a; for (int i=1;i<=m;i++){ int x, y; scanf("%d %d", &x, &y); adj[x].push_back(y); adj[y].push_back(x); } if (m > n-1 || q > 0) return 0; ans = 0; for (auto &x:adj[root]) dfs(x, root); printf("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 74 ms | 18060 KB | Output is correct |
3 | Correct | 78 ms | 18164 KB | Output is correct |
4 | Correct | 83 ms | 18124 KB | Output is correct |
5 | Correct | 73 ms | 18124 KB | Output is correct |
6 | Correct | 73 ms | 18020 KB | Output is correct |
7 | Correct | 78 ms | 18048 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 74 ms | 18060 KB | Output is correct |
3 | Correct | 78 ms | 18164 KB | Output is correct |
4 | Correct | 83 ms | 18124 KB | Output is correct |
5 | Correct | 73 ms | 18124 KB | Output is correct |
6 | Correct | 73 ms | 18020 KB | Output is correct |
7 | Correct | 78 ms | 18048 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 76 ms | 15928 KB | Output is correct |
11 | Correct | 77 ms | 18096 KB | Output is correct |
12 | Correct | 77 ms | 18048 KB | Output is correct |
13 | Correct | 82 ms | 18036 KB | Output is correct |
14 | Correct | 77 ms | 18084 KB | Output is correct |
15 | Correct | 77 ms | 18196 KB | Output is correct |
16 | Correct | 81 ms | 17456 KB | Output is correct |
17 | Correct | 80 ms | 17708 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 74 ms | 18060 KB | Output is correct |
3 | Correct | 78 ms | 18164 KB | Output is correct |
4 | Correct | 83 ms | 18124 KB | Output is correct |
5 | Correct | 73 ms | 18124 KB | Output is correct |
6 | Correct | 73 ms | 18020 KB | Output is correct |
7 | Correct | 78 ms | 18048 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 76 ms | 15928 KB | Output is correct |
11 | Correct | 77 ms | 18096 KB | Output is correct |
12 | Correct | 77 ms | 18048 KB | Output is correct |
13 | Correct | 82 ms | 18036 KB | Output is correct |
14 | Correct | 77 ms | 18084 KB | Output is correct |
15 | Correct | 77 ms | 18196 KB | Output is correct |
16 | Correct | 81 ms | 17456 KB | Output is correct |
17 | Correct | 80 ms | 17708 KB | Output is correct |
18 | Correct | 2 ms | 4948 KB | Output is correct |
19 | Correct | 137 ms | 15144 KB | Output is correct |
20 | Correct | 131 ms | 14724 KB | Output is correct |
21 | Correct | 96 ms | 12168 KB | Output is correct |
22 | Correct | 103 ms | 12544 KB | Output is correct |
23 | Correct | 96 ms | 13260 KB | Output is correct |
24 | Correct | 101 ms | 13280 KB | Output is correct |
25 | Correct | 95 ms | 13152 KB | Output is correct |
26 | Correct | 94 ms | 13028 KB | Output is correct |
27 | Correct | 95 ms | 13128 KB | Output is correct |
28 | Correct | 142 ms | 17196 KB | Output is correct |
29 | Correct | 151 ms | 14820 KB | Output is correct |
30 | Correct | 98 ms | 13864 KB | Output is correct |
31 | Correct | 90 ms | 13052 KB | Output is correct |
32 | Correct | 97 ms | 12792 KB | Output is correct |
33 | Correct | 126 ms | 12308 KB | Output is correct |
34 | Correct | 134 ms | 12432 KB | Output is correct |
35 | Correct | 108 ms | 13276 KB | Output is correct |
36 | Correct | 92 ms | 13076 KB | Output is correct |
37 | Correct | 94 ms | 13264 KB | Output is correct |
38 | Correct | 114 ms | 14520 KB | Output is correct |
39 | Correct | 116 ms | 15644 KB | Output is correct |
40 | Correct | 103 ms | 13668 KB | Output is correct |
41 | Correct | 129 ms | 18340 KB | Output is correct |
42 | Correct | 134 ms | 17872 KB | Output is correct |
43 | Correct | 93 ms | 12292 KB | Output is correct |
44 | Correct | 118 ms | 12556 KB | Output is correct |
45 | Correct | 110 ms | 12488 KB | Output is correct |
46 | Correct | 108 ms | 12360 KB | Output is correct |
47 | Correct | 120 ms | 12640 KB | Output is correct |
48 | Correct | 115 ms | 12456 KB | Output is correct |
49 | Correct | 117 ms | 12420 KB | Output is correct |
50 | Correct | 109 ms | 12484 KB | Output is correct |
51 | Correct | 117 ms | 12604 KB | Output is correct |
52 | Correct | 112 ms | 12396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 74 ms | 18060 KB | Output is correct |
3 | Correct | 78 ms | 18164 KB | Output is correct |
4 | Correct | 83 ms | 18124 KB | Output is correct |
5 | Correct | 73 ms | 18124 KB | Output is correct |
6 | Correct | 73 ms | 18020 KB | Output is correct |
7 | Correct | 78 ms | 18048 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 76 ms | 15928 KB | Output is correct |
11 | Correct | 77 ms | 18096 KB | Output is correct |
12 | Correct | 77 ms | 18048 KB | Output is correct |
13 | Correct | 82 ms | 18036 KB | Output is correct |
14 | Correct | 77 ms | 18084 KB | Output is correct |
15 | Correct | 77 ms | 18196 KB | Output is correct |
16 | Correct | 81 ms | 17456 KB | Output is correct |
17 | Correct | 80 ms | 17708 KB | Output is correct |
18 | Correct | 2 ms | 4948 KB | Output is correct |
19 | Correct | 137 ms | 15144 KB | Output is correct |
20 | Correct | 131 ms | 14724 KB | Output is correct |
21 | Correct | 96 ms | 12168 KB | Output is correct |
22 | Correct | 103 ms | 12544 KB | Output is correct |
23 | Correct | 96 ms | 13260 KB | Output is correct |
24 | Correct | 101 ms | 13280 KB | Output is correct |
25 | Correct | 95 ms | 13152 KB | Output is correct |
26 | Correct | 94 ms | 13028 KB | Output is correct |
27 | Correct | 95 ms | 13128 KB | Output is correct |
28 | Correct | 142 ms | 17196 KB | Output is correct |
29 | Correct | 151 ms | 14820 KB | Output is correct |
30 | Correct | 98 ms | 13864 KB | Output is correct |
31 | Correct | 90 ms | 13052 KB | Output is correct |
32 | Correct | 97 ms | 12792 KB | Output is correct |
33 | Correct | 126 ms | 12308 KB | Output is correct |
34 | Correct | 134 ms | 12432 KB | Output is correct |
35 | Correct | 108 ms | 13276 KB | Output is correct |
36 | Correct | 92 ms | 13076 KB | Output is correct |
37 | Correct | 94 ms | 13264 KB | Output is correct |
38 | Correct | 114 ms | 14520 KB | Output is correct |
39 | Correct | 116 ms | 15644 KB | Output is correct |
40 | Correct | 103 ms | 13668 KB | Output is correct |
41 | Correct | 129 ms | 18340 KB | Output is correct |
42 | Correct | 134 ms | 17872 KB | Output is correct |
43 | Correct | 93 ms | 12292 KB | Output is correct |
44 | Correct | 118 ms | 12556 KB | Output is correct |
45 | Correct | 110 ms | 12488 KB | Output is correct |
46 | Correct | 108 ms | 12360 KB | Output is correct |
47 | Correct | 120 ms | 12640 KB | Output is correct |
48 | Correct | 115 ms | 12456 KB | Output is correct |
49 | Correct | 117 ms | 12420 KB | Output is correct |
50 | Correct | 109 ms | 12484 KB | Output is correct |
51 | Correct | 117 ms | 12604 KB | Output is correct |
52 | Correct | 112 ms | 12396 KB | Output is correct |
53 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
54 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 74 ms | 18060 KB | Output is correct |
3 | Correct | 78 ms | 18164 KB | Output is correct |
4 | Correct | 83 ms | 18124 KB | Output is correct |
5 | Correct | 73 ms | 18124 KB | Output is correct |
6 | Correct | 73 ms | 18020 KB | Output is correct |
7 | Correct | 78 ms | 18048 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 76 ms | 15928 KB | Output is correct |
11 | Correct | 77 ms | 18096 KB | Output is correct |
12 | Correct | 77 ms | 18048 KB | Output is correct |
13 | Correct | 82 ms | 18036 KB | Output is correct |
14 | Correct | 77 ms | 18084 KB | Output is correct |
15 | Correct | 77 ms | 18196 KB | Output is correct |
16 | Correct | 81 ms | 17456 KB | Output is correct |
17 | Correct | 80 ms | 17708 KB | Output is correct |
18 | Correct | 2 ms | 4948 KB | Output is correct |
19 | Correct | 137 ms | 15144 KB | Output is correct |
20 | Correct | 131 ms | 14724 KB | Output is correct |
21 | Correct | 96 ms | 12168 KB | Output is correct |
22 | Correct | 103 ms | 12544 KB | Output is correct |
23 | Correct | 96 ms | 13260 KB | Output is correct |
24 | Correct | 101 ms | 13280 KB | Output is correct |
25 | Correct | 95 ms | 13152 KB | Output is correct |
26 | Correct | 94 ms | 13028 KB | Output is correct |
27 | Correct | 95 ms | 13128 KB | Output is correct |
28 | Correct | 142 ms | 17196 KB | Output is correct |
29 | Correct | 151 ms | 14820 KB | Output is correct |
30 | Correct | 98 ms | 13864 KB | Output is correct |
31 | Correct | 90 ms | 13052 KB | Output is correct |
32 | Correct | 97 ms | 12792 KB | Output is correct |
33 | Correct | 126 ms | 12308 KB | Output is correct |
34 | Correct | 134 ms | 12432 KB | Output is correct |
35 | Correct | 108 ms | 13276 KB | Output is correct |
36 | Correct | 92 ms | 13076 KB | Output is correct |
37 | Correct | 94 ms | 13264 KB | Output is correct |
38 | Correct | 114 ms | 14520 KB | Output is correct |
39 | Correct | 116 ms | 15644 KB | Output is correct |
40 | Correct | 103 ms | 13668 KB | Output is correct |
41 | Correct | 129 ms | 18340 KB | Output is correct |
42 | Correct | 134 ms | 17872 KB | Output is correct |
43 | Correct | 93 ms | 12292 KB | Output is correct |
44 | Correct | 118 ms | 12556 KB | Output is correct |
45 | Correct | 110 ms | 12488 KB | Output is correct |
46 | Correct | 108 ms | 12360 KB | Output is correct |
47 | Correct | 120 ms | 12640 KB | Output is correct |
48 | Correct | 115 ms | 12456 KB | Output is correct |
49 | Correct | 117 ms | 12420 KB | Output is correct |
50 | Correct | 109 ms | 12484 KB | Output is correct |
51 | Correct | 117 ms | 12604 KB | Output is correct |
52 | Correct | 112 ms | 12396 KB | Output is correct |
53 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
54 | Halted | 0 ms | 0 KB | - |