fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define f first
  5. #define s second
  6. #define GG ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  7. int main () { GG;
  8. int t=1; cin>>t;
  9. while(t--){
  10. int n,b=0,s=0,ans=0; cin>>n;
  11. int a[n];
  12. for(int i=0;i<n;i++) cin>>a[i];
  13.  
  14. for(int i=0;i<n;i++)
  15. {
  16. if(a[i]>= b)
  17. { if(a[i]==s)
  18. ans++;
  19. b=a[i];
  20. }
  21. else if( b == (s-b)+a[i] )
  22. {
  23. ans++;
  24.  
  25. }
  26. s+=a[i];
  27. }
  28.  
  29.  
  30.  
  31. cout<<ans<<"\n";
  32. }return 0;}
Success #stdin #stdout 0.01s 5284KB
stdin
7
1
0
1
1
4
1 1 2 0
5
0 1 2 1 4
7
1 1 0 3 5 2 12
7
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 294967296
10
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 589934592
stdout
1
0
3
3
4
2
2