From 5b3cd0502284abe30b148248cf808237b823edb1 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Thu, 16 Oct 2025 15:33:06 +0900 Subject: [PATCH] =?UTF-8?q?[20251016]=20BOJ=20/=20G5=20/=20=EC=82=AC?= =?UTF-8?q?=EA=B3=BC=EB=82=98=EB=AC=B4=20/=20=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\352\263\274\353\202\230\353\254\264.md" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "suyeun84/202510/16 BOJ G5 \354\202\254\352\263\274\353\202\230\353\254\264.md" diff --git "a/suyeun84/202510/16 BOJ G5 \354\202\254\352\263\274\353\202\230\353\254\264.md" "b/suyeun84/202510/16 BOJ G5 \354\202\254\352\263\274\353\202\230\353\254\264.md" new file mode 100644 index 00000000..bb108aab --- /dev/null +++ "b/suyeun84/202510/16 BOJ G5 \354\202\254\352\263\274\353\202\230\353\254\264.md" @@ -0,0 +1,33 @@ +```java +import java.io.*; +import java.util.*; + +public class boj20002 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception { st = new StringTokenizer(br.readLine()); } + static int nextInt() { return Integer.parseInt(st.nextToken()); } + + public static void main(String[] args) throws Exception { + nextLine(); + int N = nextInt(); + int[][] arr = new int[N+1][N+1]; + int answer = -1000*300*300-1; + for (int i = 1; i <= N; i++) { + nextLine(); + for (int j = 1; j <= N; j++) { + int tmp = nextInt(); + arr[i][j] = tmp + arr[i-1][j] + arr[i][j-1] - arr[i-1][j-1]; + } + } + for (int k = 1; k <= N; k++) { + for (int i = k; i <= N; i++) { + for (int j = k; j <= N; j++) { + answer = Math.max(answer, arr[i][j] - arr[i][j-k] - arr[i-k][j] + arr[i-k][j-k]); + } + } + } + System.out.println(answer); + } +} +```