The Quidditch match

0

0 votes
Problem

There are N days left for the Quidditch Match between Gryffindor and Slytherin

Madam Hooch , the Quidditch Coach of Hogwarts has decided to schedule practice of Quidditch for Gryffindor and Slytherin, but wishes to have alternating days for both. i.e, if on a day Slytherin practices, Gryffindor practices the next day and vice versa and on a day, only one team can practice. 

Harry has made a schedule as an array A of 1s and 0s. "1" denotes the days Gryffindor practices and "0" as the days they don't. (i.e Slytherin practices on those days)

Madam Hooch doesn't seem to be satisfied with Harry's random schedule .She asks Harry to modify his schedule so that both teams practice on alternate days. For each 0 converted to 1X points are taken from Gryffindor while for each 1 converted to 0Y points are taken from Gryffindor. Harry needs to take care of the House cup as well as has to ensure that minimum points are taken from Gryffindor. 

 

What is the minimum points that could be taken from Gryffindor?

Input format

  • The first line contains T the number of test cases.
  • The first line of each test case contains three space-separated integers N, Y and X.
  • The second line consists of X space-separated integers of array A.

Output format

  • For each test case, print one line denoting the minimum points taken from Gryffindor in  changing A

Constraints:

  • 1T100
  • 1N30
  • 1X,Y600
Sample Input
2
2 1 1
1 1
2 1 1
0 1
Sample Output
1
0
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

For the first test case
Harry's schedule : 1 1
He can either make it "0 1" losing 1 point   OR  "1 0" losing 1 point.
So total points deducted = 1

For the second test case
Harry's schedule : 0 1
This already satisfies Madam Hooch's condition . 
So total points deducted = 0

Editor Image

?