Skip to content

Commit

Permalink
Baekjoon #1912
Browse files Browse the repository at this point in the history
  • Loading branch information
allrightDJ0108 committed Aug 1, 2023
1 parent 4a07994 commit 53c9e95
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Binary file not shown.
32 changes: 32 additions & 0 deletions CodingTestStudy1.0/src/DynamicProgramming/Problem1912.java
@@ -0,0 +1,32 @@
package DynamicProgramming;

import java.io.*;
import java.util.*;

public class Problem1912 {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer str;

int N = Integer.parseInt(br.readLine());
int[] arr = new int[N];
int[] dp = new int[N];

str = new StringTokenizer(br.readLine());

for (int i=0; i<N; i++) {
arr[i] = Integer.parseInt(str.nextToken());
}

dp[0] = arr[0];
int result = dp[0];

for (int i=1; i<N; i++) {
dp[i] = Math.max(dp[i-1] + arr[i], arr[i]);
if (result < dp[i]) result = dp[i];
}

System.out.println(result);
}
}

0 comments on commit 53c9e95

Please sign in to comment.