Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int tt;
- cin >> tt;
- while(tt--){
- int n;
- cin >> n;
- vector<int> a(n);
- int sum = 0;
- for(int i = 0; i < n; ++i){
- cin >> a[i];
- sum += a[i];
- }
- int ans = 0;
- int maxi = 0;
- for(int i = 0; i < n; ++i){
- if(a[i] + ans > 0){
- ans += a[i];
- maxi = max(maxi, ans);
- }
- }
- if(maxi >= sum){
- cout << "NO" << endl;
- }
- else{
- cout << "YES" << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement