-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathb.cpp
36 lines (34 loc) · 888 Bytes
/
b.cpp
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int T;
ofstream fout("b.out");
cin >> T;
for(int testcase = 0; testcase < T; testcase++){
ll N, c[100000], total = 0, tmax = INT_MIN, current;
cin >> N;
for(int i = 0; i < N; i++){
cin >> c[i];
total += c[i];
tmax = max(c[i], tmax);
}
for(int add = 0; add < 2; add++){
current = 0;
for(int i = 0 + add; i < N - 1 + add; i++){
if(current + c[i] > 0){
current += c[i];
tmax = max(current, tmax);
}else{
current = 0;
}
}
}
if(total > tmax){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
return 0;
}