forked from jxixeun/jxix_java_algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ1912.java
More file actions
24 lines (22 loc) · 777 Bytes
/
Copy pathBOJ1912.java
File metadata and controls
24 lines (22 loc) · 777 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
package baekjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class BOJ1912 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int [] dp = new int[N+1];
StringTokenizer st = new StringTokenizer(br.readLine());
dp[0] = 0;
int max = Integer.MIN_VALUE;
for (int i = 1; i <= N ; i++) {
dp[i] = Integer.parseInt(st.nextToken());
dp[i] = Math.max(dp[i-1] + dp[i], dp[i]);
if (dp[i] > max)
max = dp[i];
}
System.out.println(max);
}
}