[Solution] Party Codeforces Solution | Solution Codeforces
A club plans to hold a party and will invite some of its members. The members are identified by the numbers . If member is not invited, the party will gain an unhappiness value of .
There are pairs of friends among the members. As per tradition, if both people from a friend pair are invited, they will share a cake at the party. The total number of cakes eaten will be equal to the number of pairs of friends such that both members have been invited.
However, the club's oven can only cook two cakes at a time. So, the club demands that the total number of cakes eaten is an even number.
What is the minimum possible total unhappiness value of the party, respecting the constraint that the total
number of cakes eaten is even?
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and (, ) — the number of club members and pairs of friends.
The second line of each test case contains integers () — the unhappiness value array.
Each of the next lines contains two integers and (, ) indicating that and are friends. Each unordered pair appears at most once in each test case.
It is guaranteed that both the sum of and the sum of over all test cases do not exceed .
For each test case, print a line containing a single integer – the minimum possible unhappiness value of a valid party.
No comments:
Post a Comment