-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnon_zero.cpp
More file actions
executable file
·41 lines (33 loc) · 877 Bytes
/
non_zero.cpp
File metadata and controls
executable file
·41 lines (33 loc) · 877 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
// g++ non_zero.cpp -o non_zero && ./non_zero
/*
*/
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL)
#define endl '\n'
#define ll long long int
using namespace std;
#define pii pair <ll , ll >
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define loop(x) for (int i = 0; i < x; i++)
#define vin vector<int>
int main(){
fastio;
int t, n, temp, zeros, sum;
cin >> t;
while(t--){
cin >> n;
zeros = 0;
sum = 0;
loop(n){
cin >> temp;
if(!temp) zeros++;
sum += temp;
}
if(sum <= 0){
if(abs(sum) == zeros) zeros++;
}
cout << zeros << endl;
}
}