Skip to content

Commit 5b3cd05

Browse files
authored
[20251016] BOJ / G5 / 사과나무 / 김수연
1 parent e5f0be6 commit 5b3cd05

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class boj20002 {
6+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
static StringTokenizer st;
8+
static void nextLine() throws Exception { st = new StringTokenizer(br.readLine()); }
9+
static int nextInt() { return Integer.parseInt(st.nextToken()); }
10+
11+
public static void main(String[] args) throws Exception {
12+
nextLine();
13+
int N = nextInt();
14+
int[][] arr = new int[N+1][N+1];
15+
int answer = -1000*300*300-1;
16+
for (int i = 1; i <= N; i++) {
17+
nextLine();
18+
for (int j = 1; j <= N; j++) {
19+
int tmp = nextInt();
20+
arr[i][j] = tmp + arr[i-1][j] + arr[i][j-1] - arr[i-1][j-1];
21+
}
22+
}
23+
for (int k = 1; k <= N; k++) {
24+
for (int i = k; i <= N; i++) {
25+
for (int j = k; j <= N; j++) {
26+
answer = Math.max(answer, arr[i][j] - arr[i][j-k] - arr[i-k][j] + arr[i-k][j-k]);
27+
}
28+
}
29+
}
30+
System.out.println(answer);
31+
}
32+
}
33+
```

0 commit comments

Comments
 (0)