## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Party Codeforces Solution | Solution Codeforces

B. Party
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A club plans to hold a party and will invite some of its $n$ members. The $n$ members are identified by the numbers $1,2,\dots ,n$. If member $i$ is not invited, the party will gain an unhappiness value of ${a}_{i}$.

There are $m$ pairs of friends among the $n$ 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

Solution Click Below:-  👉
👇👇👇👇👇

number of cakes eaten is even?

Input

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\le t\le {10}^{4}$). The description of the test cases follows.

The first line of each test case contains two integers $n$ and $m$ ($1\le n\le {10}^{5}$$0\le m\le min\left({10}^{5},\frac{n\left(n-1\right)}{2}\right)$) — the number of club members and pairs of friends.

The second line of each test case contains $n$ integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$ ($0\le {a}_{i}\le {10}^{4}$) — the unhappiness value array.

Each of the next $m$ lines contains two integers $x$ and $y$ ($1\le x,y\le n$$x\ne y$) indicating that $x$ and $y$ are friends. Each unordered pair $\left(x,y\right)$ appears at most once in each test case.

It is guaranteed that both the sum of $n$ and the sum of $m$ over all test cases do not exceed ${10}^{5}$.

Output

For each test case, print a line containing a single integer – the minimum possible unhappiness value of a valid party.