-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Unit_Array.cpp
More file actions
42 lines (39 loc) · 939 Bytes
/
A_Unit_Array.cpp
File metadata and controls
42 lines (39 loc) · 939 Bytes
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
/*____________________________________________________
|Author: Ki6ui-Par1na
|Date: 2024/06/06
|Time: 20:48:52
|Problem: A_Unit_Array
|____________________________________________________*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define print(n) cout << (n) << endl;
#define tc ll t; cin >> t; while(t--)
void solve() {
tc{
int n; cin >> n;
vector<int> v(n);
for(auto &i : v) cin >> i;
int cn1 = 0, cn2 = 0;
int ans = 0;
for(int i = 0; i < n; i++){
if(v[i] > 0) cn1++;
else cn2++;
}
while((cn1 - cn2) < 0 or (cn2 % 2 != 0)){
cn1++;
cn2--;
ans++;
}
cout << ans << endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
solve();
return 0;
}