PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000472. Xóa đỉnh (Erasing Vertices 2)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Xóa đỉnh (Erasing Vertices 2)
Erasing Vertices 2
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A simple undirected graph has positive vertex values . Delete one remaining vertex and its incident edges at each step. The cost is the sum of values of its remaining neighbors before deletion. Remove all vertices, minimizing the largest step cost.
Input
Read , the values , then pairs .
Output
Print the minimum possible maximum cost.
Subtasks
Subtask 1 (20 points)
- ,
- , , ; no parallel edges; all data are integers.
Subtask 2 (30 points)
- ,
- , , ; no parallel edges; all data are integers.
Subtask 3 (50 points)
- ,
- , , ; no parallel edges; all data are integers.
Examples
Example 1
Input
4 3
3 1 4 2
1 2
1 3
4 1
Output
3
Explanation
Delete 3, 1, 2, 4 with costs 3, 3, 0, 0. Every initial cost is at least 3.
Example 2
Input
7 13
464 661 847 514 74 200 188
5 1
7 1
5 7
4 1
4 5
2 4
5 2
1 3
1 6
3 5
1 2
4 6
2 7
Output
1199
Explanation
The threshold 1199 permits all vertices to be removed; threshold 1198 does not.