From 1ce2430758fc64c9314af3ed81ce635002077e7f Mon Sep 17 00:00:00 2001 From: oncsr Date: Sat, 13 Sep 2025 14:45:00 +0900 Subject: [PATCH] =?UTF-8?q?[20250913]=20BOJ=20/=20G4=20/=20=ED=8C=80=20?= =?UTF-8?q?=EB=B9=8C=EB=94=A9=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \355\214\200 \353\271\214\353\224\251.md" | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 "khj20006/202509/13 BOJ G4 \355\214\200 \353\271\214\353\224\251.md" diff --git "a/khj20006/202509/13 BOJ G4 \355\214\200 \353\271\214\353\224\251.md" "b/khj20006/202509/13 BOJ G4 \355\214\200 \353\271\214\353\224\251.md" new file mode 100644 index 00000000..ad76ae39 --- /dev/null +++ "b/khj20006/202509/13 BOJ G4 \355\214\200 \353\271\214\353\224\251.md" @@ -0,0 +1,86 @@ +```java +import java.io.*; +import java.util.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) + nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N; + static int[] min, max; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + N = io.nextInt(); + min = new int[10001]; + max = new int[10001]; + for(int i=1;i<=N;i++) { + int a = io.nextInt(); + if(min[a] == 0) min[a] = i; + max[a] = i; + } + + int ans = 0; + for(int i=1;i<=10000;i++) for(int j=1;j<=10000;j++) { + if(max[i] == 0 || max[j] == 0 || max[j] == min[i]) continue; + ans = Math.max(ans, Math.min(i,j) * (max[j] - min[i] - 1)); + } + + io.write(ans + "\n"); + + io.close(); + + } + +} +```