#P2128. Red Cliffs Deception

    ID: 15409 Type: Default 1000ms 256MiB

Red Cliffs Deception

Red Cliffs Deception

In the famous Battle of Red Cliffs, Huang Gai once loaded his fleet with combustible materials to deceive the enemy. Following the ingenious "chain strategy" taught by Pang Tong, the enemy ships are connected pair‐wise by iron chains. The arrangement guarantees that no two ships share the same location and the chains do not intersect or pass through any ship. Each enemy ship has a strategic value. In order to achieve maximum destructive effect, Huang Gai must choose a set of enemy ships to ignite such that any two ignited ships are directly linked by an iron chain. Formally, if the set of selected ships is (S) and the set of iron chains (edges) is (E), then for every two distinct ships (u,v \in S) it must hold that ( (u,v) \in E ). Your task is to choose such a subset of ships so that the total strategic value is maximized.

inputFormat

The input begins with a line containing two integers (n) and (m) representing the number of enemy ships and the number of iron chains respectively. The next line contains (n) integers where the (i)-th integer denotes the strategic value of the (i)-th ship. Each of the following (m) lines contains two integers (u) and (v) (1-based indexing) indicating that there is an iron chain connecting ship (u) and ship (v).

outputFormat

Output a single integer — the maximum total strategic value that can be achieved by selecting a subset of ships that forms a clique (i.e. every two selected ships are directly connected by an iron chain).

sample

4 5
3 5 2 6
1 2
1 3
2 3
2 4
3 4
13