-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoliceRecruits.java
More file actions
32 lines (29 loc) · 917 Bytes
/
PoliceRecruits.java
File metadata and controls
32 lines (29 loc) · 917 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
30
31
32
/**
* Created by MalhotR1 on 2/8/2017.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class PoliceRecruits {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int events = Integer.parseInt(br.readLine().trim());
String[] input = br.readLine().trim().split(" ");
int[] arr = new int[input.length];
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(input[i]);
}
int p_cnt = 0;
int c_cnt = 0;
int res = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == -1){
if (p_cnt == 0) res++;
else p_cnt--;
} else {
p_cnt += arr[i];
}
}
System.out.println(res);
}
}