Advertisement
Goga21

Untitled

Jun 11th, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define int long long
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  void solve(){
  9.     int n;
  10.         cin >> n;
  11.         vector<int> v(n);
  12.         for(int i = 0; i < n; ++i){
  13.             cin >> v[i];
  14.         }
  15.         int sum = 0, mx = 0, ans = 0;
  16.         for(int i = 0; i < n; ++i){
  17.             sum += v[i];
  18.             mx = max(mx, v[i]);
  19.             if( sum - 2 * mx == 0) ++ans;
  20.         }
  21.         cout << ans << '\n';
  22.  }
  23. signed main(){
  24.     ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
  25.     int t;
  26.     cin >> t;
  27.     while(t--){
  28.         solve();
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement