-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ11048.java
More file actions
35 lines (28 loc) · 787 Bytes
/
Copy pathBOJ11048.java
File metadata and controls
35 lines (28 loc) · 787 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
33
34
35
package quki.algorithm.dp;
import java.util.Scanner;
/**
* À̵¿Çϱâ
*
* @author quki
*/
public class BOJ11048 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int a[][] = new int[n + 1][m + 1];
int d[][] = new int[n + 1][m + 1];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
a[i][j] = sc.nextInt();
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
int max = Math.max(d[i - 1][j - 1], d[i - 1][j]);
d[i][j] = Math.max(max, d[i][j - 1]) + a[i][j];
}
}
System.out.println(d[n][m]);
}
}