We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a9ded0f commit 9fea81dCopy full SHA for 9fea81d
1834A-UnitArray.cpp
@@ -0,0 +1,25 @@
1
+#include <cstdio>
2
+
3
+int main(){
4
5
+ long t; scanf("%ld", &t);
6
+ while(t--){
7
+ long n; scanf("%ld", &n);
8
+ long pos(0), neg(0);
9
+ for(long p = 0; p < n; p++){
10
+ int x; scanf("%d", &x);
11
+ pos += (x > 0);
12
+ neg += (x < 0);
13
+ }
14
15
+ long move(0);
16
+ if(pos < neg){
17
+ move = (neg - pos + 1) / 2;
18
+ pos += move; neg -= move;
19
20
+ if(neg % 2){++move;}
21
22
+ printf("%ld\n", move);
23
24
25
+}
0 commit comments