#P2057. [SHOI2007] 善意的投票 / [JLOI2010] 冠军调查
[SHOI2007] 善意的投票 / [JLOI2010] 冠军调查
Description
In a kindergarten, there are children who plan to decide whether to take a nap by voting.
This issue is not very important to them, so they decide to be considerate.
Although everyone has their own preference, they may cast a vote opposite to their original intention to accommodate their friends.
We define the conflict count of a voting result as the sum of the following two quantities:
- The number of friend pairs whose actual votes differ.
- The number of children whose actual vote differs from their original preference.
Our problem is: how should each child vote to minimize the conflict count?
Input Format
The first line contains two integers , where is the total number of children and is the number of friend pairs.
The second line contains integers. The -th integer is the -th child’s preference: means agreeing to take a nap, and means opposing it.
The next lines each contain two integers , indicating that and are a pair of friends. We guarantee that any pair does not repeat.
Output Format
Output a single integer on one line: the minimum possible conflict count.
3 3
1 0 0
1 2
1 3
3 2
1
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号