Skip to content

Commit 8f1d27f

Browse files
authored
Create Watermelon.java
1 parent 124b1f9 commit 8f1d27f

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

Codechef/LTIME88B/Watermelon.java

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import java.util.*;
2+
import java.lang.*;
3+
import java.io.*;
4+
5+
class Codechef
6+
{
7+
static class FastReader
8+
{
9+
BufferedReader br;
10+
StringTokenizer st;
11+
12+
public FastReader()
13+
{
14+
br = new BufferedReader(new
15+
InputStreamReader(System.in));
16+
}
17+
18+
String next()
19+
{
20+
while (st == null || !st.hasMoreElements())
21+
{
22+
try
23+
{
24+
st = new StringTokenizer(br.readLine());
25+
}
26+
catch (IOException e)
27+
{
28+
e.printStackTrace();
29+
}
30+
}
31+
return st.nextToken();
32+
}
33+
34+
int nextInt()
35+
{
36+
return Integer.parseInt(next());
37+
}
38+
39+
long nextLong()
40+
{
41+
return Long.parseLong(next());
42+
}
43+
44+
double nextDouble()
45+
{
46+
return Double.parseDouble(next());
47+
}
48+
49+
String nextLine()
50+
{
51+
String str = "";
52+
try
53+
{
54+
str = br.readLine();
55+
}
56+
catch (IOException e)
57+
{
58+
e.printStackTrace();
59+
}
60+
return str;
61+
}
62+
}
63+
public static void main (String[] args) throws java.lang.Exception
64+
{
65+
// your code goes here
66+
FastReader sc=new FastReader();
67+
int t=sc.nextInt();
68+
while(t-->0) {
69+
int n=sc.nextInt();
70+
int[] arr=new int[n];
71+
long sum=0,cp=0,cn=0;
72+
for(int i=0;i<n;i++) {
73+
arr[i]=sc.nextInt();
74+
sum=sum+arr[i];
75+
if(arr[i]>0) {
76+
cp=cp+arr[i];
77+
}
78+
if(arr[i]<0) {
79+
cn=cn-arr[i];
80+
}
81+
}
82+
if(sum==0) {
83+
System.out.println("YES");
84+
}
85+
else {
86+
if(cp>cn) {
87+
System.out.println("YES");
88+
}
89+
else {
90+
System.out.println("NO");
91+
}
92+
}
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)