用户输出
16 4
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#63504 | #1230. czq的大陆划分 | Accepted | 100 | 115 ms | 1424 K | C++ 11 (NOI) / 849 B | Lrefrain | 2021-08-10 14:05:23 |
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
inline void read(int &x) {
x = 0;
char c = getchar();
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - 48, c = getchar();
}
typedef long long ll;
const int maxn = 1e5 + 5, INF = 2e9 + 5;
int mx, mn = INF, n, m, a[maxn], fa[maxn], w[maxn];
int find(int x) {
if (fa[x] == x)
return x;
return fa[x] = find(fa[x]);
}
void merge(int x, int y) {
int fx = find(x), fy = find(y);
if (fx != fy)
fa[fx] = fy;
}
int main() {
read(n), read(m);
for (int i = 1; i <= n; ++i) read(a[i]), fa[i] = i;
for (int i = 1, x, y; i <= m; ++i) read(x), read(y), merge(x, y);
for (int i = 1; i <= n; ++i) w[find(i)] += a[i];
for (int i = 1; i <= n; ++i)
if (w[i])
mx = max(mx, w[i]), mn = min(mn, w[i]);
printf("%d %d\n", mx, mn);
return 0;
}
用户输出
16 4
系统信息
Exited with return code 0
用户输出
405 21
系统信息
Exited with return code 0
20 7
24 94 92 33 83 19 65 94 15 79 22 51 30 19 96 25 9 84 7 71
10 5
11 8
20 2
16 15
9 5
2 1
6 15
用户输出
189 7
系统信息
Exited with return code 0
20 37
25 74 84 70 6 13 4 15 63 11 29 17 88 11 27 31 46 68 96 22
4 3
4 7
7 2
17 13
17 3
18 13
2 8
19
<148 bytes omitted>
用户输出
800 800
系统信息
Exited with return code 0
36 60
82 45 88 53 71 14 79 53 95 31 18 29 47 28 76 8 23 95 27 49 68 28 13 84 92 87 46 6 81 59 14 81
<349 bytes omitted>
用户输出
1825 18
系统信息
Exited with return code 0
1000 200000
15 80 53 66 43 59 37 92 87 43 15 4 60 43 93 48 60 78 6 19 53 80 11 15 77 58 17 99 49 32
<1559923 bytes omitted>
用户输出
51531 51531
系统信息
Exited with return code 0
100000 200000
10 51 19 39 90 60 88 51 99 84 31 80 86 28 48 12 90 57 31 30 80 53 72 40 87 88 97 95 33
<2649891 bytes omitted>
用户输出
5047338 3
系统信息
Exited with return code 0
10000 200000
22 28 8 98 60 84 50 55 48 68 4 28 84 66 67 21 9 71 24 22 51 14 98 9 53 42 69 47 65 63 6
<1984655 bytes omitted>
用户输出
514235 514235
系统信息
Exited with return code 0
100000 2000
33 50 86 15 90 51 63 84 45 80 5 23 7 63 60 72 90 13 26 18 82 36 76 27 80 75 57 7 72 76 6
<317397 bytes omitted>
用户输出
293 3
系统信息
Exited with return code 0
100000 99998
47 17 70 10 26 8 86 85 86 83 57 28 99 58 35 57 37 58 23 3 23 73 61 83 82 48 71 17 75 30
<1471461 bytes omitted>
用户输出
2577991 2572837
系统信息
Exited with return code 0