forked from GreatAlgorithm-Study/AlgorithmStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDH_12913.java
More file actions
27 lines (22 loc) ยท 675 Bytes
/
DH_12913.java
File metadata and controls
27 lines (22 loc) ยท 675 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
/*
๋
๋ฐ๋จน๊ธฐ
*/
public class DH_12913 {
class Solution {
int solution(int[][] land) {
int answer = 0;
int R = land.length, C = land[0].length;
int dp[][] = new int[R + 1][C];
for(int r = 1; r < R + 1; r++) {
for(int c1 = 0; c1 < C; c1++) {
for(int c2 = 0; c2 < C; c2++) {
if(c1 == c2) continue;
dp[r][c1] = Math.max(land[r - 1][c1] + dp[r - 1][c2], dp[r][c1]);
answer = Math.max(answer, dp[r][c1]);
}
}
}
return answer;
}
}
}