- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_Subarray.java
More file actions
Latest commit
29 lines (27 loc) · 701 Bytes
/
Copy pathJava_Subarray.java
File metadata and controls
29 lines (27 loc) · 701 Bytes
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
importjava.io.*;
importjava.util.*;
importjava.text.*;
importjava.math.*;
importjava.util.regex.*;
publicclassJava_Subarray {
publicstaticvoidmain(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scannersc=newScanner(System.in);
intn=sc.nextInt();
int[] array1= newint[n];
for(inti=0;i<n;i++){
array1[i]=sc.nextInt();
}
intcount=0;
for(intj=0;j<n;j++){
intsum=0;
for(intk=j;k<n;k++){
sum=array1[k]+sum;
if(sum<0){
count++;
}
}
}
System.out.println(count);
}
}