#abc267e. E - Erasing Vertices 2
E - Erasing Vertices 2
Score : points
问题描述
给定一个包含 个顶点和 条边的简单无向图。第 条边连接顶点 和 。顶点 上写有一个正整数 。
你需要重复以下操作 次:
- 选择一个尚未移除的顶点 ,然后移除顶点 及其所有关联的边。该操作的成本是与顶点 直接通过边相连且尚未移除的所有顶点上所写整数之和。
我们将整个 次操作的成本定义为单次操作成本中的最大值。求出整个操作序列的最小可能成本。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a simple undirected graph with vertices and edges. The -th edge connects Vertices and . Vertex has a positive integer written on it.
You will repeat the following operation times.
- Choose a Vertex that is not removed yet, and remove Vertex and all edges incident to Vertex . The cost of this operation is the sum of the integers written on the vertices directly connected by an edge with Vertex that are not removed yet.
We define the cost of the entire operations as the maximum of the costs of the individual operations. Find the minimum possible cost of the entire operations.
Constraints
- The given graph is simple.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 3
3 1 4 2
1 2
1 3
4 1
Sample Output 1
3
By performing the operations as follows, the maximum of the costs of the operations can be .
- Choose Vertex . The cost is .
- Choose Vertex . The cost is .
- Choose Vertex . The cost is .
- Choose Vertex . The cost is .
The maximum of the costs of the operations cannot be or less, so the solution is .
Sample Input 2
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
Sample Output 2
1199
update @ 2024/3/10 11:16:50