#abc267e. E - Erasing Vertices 2

E - Erasing Vertices 2

Score : 500500 points

问题描述

给定一个包含 NN 个顶点和 MM 条边的简单无向图。第 ii 条边连接顶点 UiU_iViV_i。顶点 ii 上写有一个正整数 AiA_i

你需要重复以下操作 NN 次:

  • 选择一个尚未移除的顶点 xx,然后移除顶点 xx 及其所有关联的边。该操作的成本是与顶点 xx 直接通过边相连且尚未移除的所有顶点上所写整数之和。

我们将整个 NN 次操作的成本定义为单次操作成本中的最大值。求出整个操作序列的最小可能成本。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a simple undirected graph with NN vertices and MM edges. The ii-th edge connects Vertices UiU_i and ViV_i. Vertex ii has a positive integer AiA_i written on it.

You will repeat the following operation NN times.

  • Choose a Vertex xx that is not removed yet, and remove Vertex xx and all edges incident to Vertex xx. The cost of this operation is the sum of the integers written on the vertices directly connected by an edge with Vertex xx that are not removed yet.

We define the cost of the entire NN operations as the maximum of the costs of the individual operations. Find the minimum possible cost of the entire operations.

Constraints

  • 1N2×1051 \le N \le 2 \times 10^5
  • 0M2×1050 \le M \le 2 \times 10^5
  • 1Ai1091 \le A_i \le 10^9
  • 1Ui,ViN1 \le U_i,V_i \le N
  • The given graph is simple.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 \dots ANA_N

U1U_1 V1V_1

U2U_2 V2V_2

\vdots

UMU_M VMV_M

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 NN operations can be 33.

  • Choose Vertex 33. The cost is A1=3A_1=3.
  • Choose Vertex 11. The cost is A2+A4=3A_2+A_4=3.
  • Choose Vertex 22. The cost is 00.
  • Choose Vertex 44. The cost is 00.

The maximum of the costs of the NN operations cannot be 22 or less, so the solution is 33.

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