编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#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;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:1 ms
内存:252 KiB

输入文件(0.in

7 5
1 9 2 6 8 1 7
1 3
3 6
6 1
4 5
7 2

答案文件(0.out

16 4

用户输出

16 4

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:1 ms
内存:316 KiB

输入文件(1.in

10 7
21 56 21 26 86 82 57 48 60 55
4 9
5 6
8 7
8 3
5 2
5 10
8 5

答案文件(1.out

405 21

用户输出

405 21

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:1 ms
内存:248 KiB

输入文件(2.in

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

答案文件(2.out

189 7

用户输出

189 7

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:1 ms
内存:208 KiB

输入文件(3.in

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>

答案文件(3.out

800 800

用户输出

800 800

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:1 ms
内存:248 KiB

输入文件(4.in

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>

答案文件(4.out

1825 18

用户输出

1825 18

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:15 ms
内存:268 KiB

输入文件(5.in

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>

答案文件(5.out

51531 51531

用户输出

51531 51531

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:39 ms
内存:1396 KiB

输入文件(6.in

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>

答案文件(6.out

5047338 3

用户输出

5047338 3

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:20 ms
内存:248 KiB

输入文件(7.in

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>

答案文件(7.out

514235 514235

用户输出

514235 514235

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:5 ms
内存:1424 KiB

输入文件(8.in

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>

答案文件(8.out

293 3

用户输出

293 3

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:15 ms
内存:1012 KiB

输入文件(9.in

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>

答案文件(9.out

2577991 2572837

用户输出

2577991 2572837

系统信息

Exited with return code 0
测试点 #11
Accepted
得分:100
用时:16 ms
内存:1020 KiB

输入文件(10.in

100000 99998
60 36 19 50 38 12 37 30 59 28 47 95 85 17 5 57 11 33 70 58 31 31 35 59 11 78 75 39 41 5
<1470466 bytes omitted>

答案文件(10.out

5149561 4774

用户输出

5149561 4774

系统信息

Exited with return code 0