From 2dea92dd3e58c9fedc8575e13114d06b4a423673 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Thu, 11 Sep 2025 19:12:45 +0900 Subject: [PATCH] =?UTF-8?q?[20250911]=20BOJ=20/=20G4=20/=20=EA=B3=A0?= =?UTF-8?q?=EC=B8=B5=20=EA=B1=B4=EB=AC=BC=20/=20=EC=9D=B4=EA=B0=95?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\270\265 \352\261\264\353\254\274.md" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "lkhyun/202509/11 BOJ G4 \352\263\240\354\270\265 \352\261\264\353\254\274.md" diff --git "a/lkhyun/202509/11 BOJ G4 \352\263\240\354\270\265 \352\261\264\353\254\274.md" "b/lkhyun/202509/11 BOJ G4 \352\263\240\354\270\265 \352\261\264\353\254\274.md" new file mode 100644 index 00000000..2435bc43 --- /dev/null +++ "b/lkhyun/202509/11 BOJ G4 \352\263\240\354\270\265 \352\261\264\353\254\274.md" @@ -0,0 +1,47 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + static int N; + static int[] buildings; + static int[] cnt; + static int max; + + public static void main(String[] args) throws IOException { + N = Integer.parseInt(br.readLine()); + buildings = new int[N+1]; + cnt = new int[N+1]; + + st = new StringTokenizer(br.readLine()); + for (int i = 1; i <= N; i++) { + buildings[i] = Integer.parseInt(st.nextToken()); + } + + for (int i = 1; i < N; i++) { + for (int j = i+1; j <= N; j++) { + double slope = (double)(buildings[j]-buildings[i]) / (j-i); + boolean isPossible = true; + for (int k = 1; i+k < j; k++) { + if(buildings[i]+(slope*k) <= buildings[i+k]){ + isPossible = false; + break; + } + } + if(isPossible){ + cnt[i]++; + cnt[j]++; + } + } + } + for (int i = 1; i <= N; i++) { + max = Math.max(cnt[i], max); + } + bw.write(max+""); + bw.close(); + } +} +```