-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpA.cpp
46 lines (37 loc) · 812 Bytes
/
pA.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <algorithm>
using namespace std;
int func() {
int lt = 0;
int count = 0;
cin >> lt;
int arr[2 * lt];
for (int i = 0; i < 2 * lt; i++) {
cin >> arr[i];
}
for (int i = 0; i < 2 * lt; i++) {
if (arr[i] == 1) {
count++;
}
}
int minlt = (count % 2 == 0) ? 0 : 1;
int maxlt ;
if (count<=lt) {
maxlt = count;
}
else if(count>lt) {
maxlt = 2*lt-count;
}
//if number smaller than n, then maximum is equal to number on switches
//if number larger than n, then maximum is equal to n-(on-n) = 2n - on
cout << minlt << " " << maxlt << endl;
return 0;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
func();
}
return 0;
}