atcoder#ABC267E. [ABC267E] Erasing Vertices 2
[ABC267E] Erasing Vertices 2
Score : points
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.
4 3
3 1 4 2
1 2
1 3
4 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 .
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
1199