From f342bd152d7d5e6d40e4fb7fe581167de12653ff Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Thu, 13 Nov 2025 13:53:30 +0900 Subject: [PATCH] =?UTF-8?q?[20251113]=20BOJ=20/=20G5=20/=20=EB=B9=97?= =?UTF-8?q?=EB=AC=BC=20/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../13 BOJ \353\271\227\353\254\274.md" | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 "0224LJH/202511/13 BOJ \353\271\227\353\254\274.md" diff --git "a/0224LJH/202511/13 BOJ \353\271\227\353\254\274.md" "b/0224LJH/202511/13 BOJ \353\271\227\353\254\274.md" new file mode 100644 index 00000000..820383a4 --- /dev/null +++ "b/0224LJH/202511/13 BOJ \353\271\227\353\254\274.md" @@ -0,0 +1,77 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.PriorityQueue; +import java.util.Queue; +import java.util.StringTokenizer; + +public class Main { + + static int height, width,ans; + static boolean[][] arr; + + + public static void main(String[] args) throws IOException { + init(); + process(); + print(); + + + } + + private static void init() throws IOException{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + height = Integer.parseInt(st.nextToken()); + width = Integer.parseInt(st.nextToken()); + + arr = new boolean[height][width]; + ans = 0; + + st = new StringTokenizer(br.readLine()); + for (int i = 0; i < width; i++) { + int h = Integer.parseInt(st.nextToken()); + for (int j = 0; j < j; j++) { + arr[j][i]= true; + } + } + + + + } + + private static void process() throws IOException { + for (int i = 0; i < height; i++) { + ArrayList idxes = new ArrayList<>(); + for (int j = 0; j < width; j++) { + if(arr[i][j]) idxes.add(j); + } + + if (idxes.size() < 2) return; + + int pre = idxes.get(0); + + for(int j = 1; j < idxes.size(); j++) { + int cur = idxes.get(i); + ans += cur - pre; + pre = cur; + } + } + + } + + + private static void print() { + System.out.print(ans); + } + +} +```