Codeforces Round 983 (Div. 2) |
---|
Finished |
Alice has just crafted a circuit with $$$n$$$ lights and $$$2n$$$ switches. Each component (a light or a switch) has two states: on or off. The lights and switches are arranged in a way that:
Alice brings the circuit, which shows only the states of the $$$2n$$$ switches, to her sister Iris and gives her a riddle: what is the minimum and maximum number of lights that can be turned on?
Knowing her little sister's antics too well, Iris takes no more than a second to give Alice a correct answer. Can you do the same?
Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of lights in the circuit.
The second line of each test case contains $$$2n$$$ integers $$$a_1, a_2, \ldots, a_{2n}$$$ ($$$0 \le a_i \le 1$$$) — the states of the switches in the circuit. $$$a_i = 0$$$ means the $$$i$$$-th switch is off, and $$$a_i = 1$$$ means the $$$i$$$-th switch is on.
For each test case, output two integers — the minimum and maximum number of lights, respectively, that can be turned on.
510 010 111 130 0 1 0 1 030 1 1 1 0 0
0 0 1 1 0 0 0 2 1 3
In the first test case, there is only one light in the circuit, and no switch is on, so the light is certainly off.
In the second test case, there is only one light in the circuit, but one switch connected to it is on, so the light is on.
In the third test case, there is only one light in the circuit, and both switches are on, so the light is off as it was toggled twice.
In the fourth test case, to have no lights on, the switches can be arranged in this way:
And to have $$$2$$$ lights on, the switches can be arranged in this way:
Name |
---|