luogu#P4643. [国家集训队] 阿狸和桃子的游戏
[国家集训队] 阿狸和桃子的游戏
Problem Description
Ali and Peach are playing a game on a weighted graph . Let the weight of a vertex be , and the weight of an edge be . The rules are:
-
Ali and Peach take turns coloring vertices in the graph. Ali colors a vertex red, and Peach colors a vertex pink. A vertex that has already been colored cannot be colored again, and in each turn, exactly one vertex must be colored.
-
To ensure fairness, the number of vertices is even.
-
After rounds, each player obtains a set of vertices. For a vertex set , the score is
Since Ali lost Rock-Paper-Scissors to Peach, Peach colors first. Both players want their own score to exceed the other’s, and the larger the difference, the better. Assuming both players use optimal strategies, find the final value of Peach’s score minus Ali’s score.
Input Format
The first line contains two positive integers and , representing the number of vertices and edges of the graph , where is guaranteed to be even.
The next lines follow.
The first lines each contain one integer . The -th of these lines gives the weight of vertex .
The next lines each contain three integers separated by spaces, describing an edge between vertices and with weight .
Output Format
Output exactly one integer, which is Peach’s score minus Ali’s score.
4 4
6
4
-1
-2
1 2 1
2 3 6
3 4 3
1 4 5
3
Hint
Constraints and notes:
For of the testdata, .
For of the testdata, , , .
Translated by ChatGPT 5