From 4d6703ca601ddbe1c2b1554629899305a2a7e2de Mon Sep 17 00:00:00 2001 From: oncsr Date: Tue, 24 Feb 2026 17:17:28 +0900 Subject: [PATCH] =?UTF-8?q?[20260224]=20BOJ=20/=20P3=20/=20=EC=B5=9C?= =?UTF-8?q?=EB=8C=80=20=EC=A7=81=EC=82=AC=EA=B0=81=ED=98=95=20/=20?= =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...01\354\202\254\352\260\201\355\230\225.md" | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 "khj20006/202602/24 BOJ P3 \354\265\234\353\214\200 \354\247\201\354\202\254\352\260\201\355\230\225.md" diff --git "a/khj20006/202602/24 BOJ P3 \354\265\234\353\214\200 \354\247\201\354\202\254\352\260\201\355\230\225.md" "b/khj20006/202602/24 BOJ P3 \354\265\234\353\214\200 \354\247\201\354\202\254\352\260\201\355\230\225.md" new file mode 100644 index 00000000..07e8bff7 --- /dev/null +++ "b/khj20006/202602/24 BOJ P3 \354\265\234\353\214\200 \354\247\201\354\202\254\352\260\201\355\230\225.md" @@ -0,0 +1,100 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + + static class IOManager { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + private IOManager(){} + + static String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + static String nextToken() throws Exception { + while (!st.hasMoreTokens()) + nextLine(); + return st.nextToken(); + } + + static int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + static long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + static double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + static void write(String content) throws Exception { + bw.write(content); + } + + public static void close() throws Exception { + bw.flush(); + bw.close(); + br.close(); + } + } + + // + + static int N, M; + static int[] arr; + + public static void main(String[] args) throws Exception { + N = IOManager.nextInt(); + M = IOManager.nextInt(); + while (Math.min(N, M) > 0) { + int ans = 0; + arr = new int[M]; + for (int i = 0; i < N; i++) { + for (int j = 0, a; j < M; j++) { + a = IOManager.nextInt(); + if (a == 1) { + arr[j]++; + } + else { + arr[j] = 0; + } + } + ans = Math.max(ans, histogram(arr)); + } + + IOManager.write(ans + "\n"); + N = IOManager.nextInt(); + M = IOManager.nextInt(); + } + IOManager.close(); + } + + public static int histogram(int[] hist) { + int ret = 0; + Stack stack = new Stack<>(); + for (int i = 0; i < hist.length; i++) { + int idx = i; + while (!stack.isEmpty() && stack.peek()[0] > hist[i]) { + ret = Math.max(ret, stack.peek()[0] * (i - stack.peek()[1])); + idx = stack.peek()[1]; + stack.pop(); + } + stack.push(new int[]{ hist[i], idx }); + } + while (!stack.isEmpty()) { + ret = Math.max(ret, stack.peek()[0] * (hist.length - stack.peek()[1])); + stack.pop(); + } + return ret; + } + +} +```