Advertisement
deushiro

Untitled

Jan 10th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. int main()
  8. {
  9.     ios_base::sync_with_stdio(false);
  10.     cin.tie(0);
  11.     cout.tie(0);
  12.     int tt;
  13.     cin >> tt;
  14.     while(tt--){
  15.         int n;
  16.         cin >> n;
  17.         vector<int> a(n);
  18.         int sum = 0;
  19.         for(int i = 0; i < n; ++i){
  20.             cin >> a[i];
  21.             sum += a[i];
  22.         }
  23.         int ans = 0;
  24.         int maxi = 0;
  25.         for(int i = 0; i < n; ++i){
  26.             if(a[i] + ans > 0){
  27.                 ans += a[i];
  28.                 maxi = max(maxi, ans);
  29.             }
  30.         }
  31.         if(maxi >= sum){
  32.             cout << "NO" << endl;
  33.         }
  34.         else{
  35.             cout << "YES" << endl;
  36.         }
  37.  
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement