From a07323a2046b203a56011d3be578b12f6e0e2a80 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Sun, 21 Dec 2025 23:56:26 +0900 Subject: [PATCH] =?UTF-8?q?[20251221]=20BOJ=20/=20G5=20/=20=EC=98=A5?= =?UTF-8?q?=EC=83=81=20=EC=A0=95=EC=9B=90=20=EA=BE=B8=EB=AF=B8=EA=B8=B0=20?= =?UTF-8?q?/=20=EC=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \352\276\270\353\257\270\352\270\260.md" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "LiiNi-coder/202512/21 BOJ \354\230\245\354\203\201 \354\240\225\354\233\220 \352\276\270\353\257\270\352\270\260.md" diff --git "a/LiiNi-coder/202512/21 BOJ \354\230\245\354\203\201 \354\240\225\354\233\220 \352\276\270\353\257\270\352\270\260.md" "b/LiiNi-coder/202512/21 BOJ \354\230\245\354\203\201 \354\240\225\354\233\220 \352\276\270\353\257\270\352\270\260.md" new file mode 100644 index 00000000..2decc688 --- /dev/null +++ "b/LiiNi-coder/202512/21 BOJ \354\230\245\354\203\201 \354\240\225\354\233\220 \352\276\270\353\257\270\352\270\260.md" @@ -0,0 +1,26 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + long answer = 0L; + + Deque stack = new ArrayDeque<>(); + + for(int i = 0; i < N; i++){ + int height = Integer.parseInt(br.readLine()); + while(!stack.isEmpty() && stack.peekLast() <= height){ + stack.pollLast(); + } + + answer += stack.size(); + stack.offerLast(height); + } + System.out.println(answer); + } +} + +```