From 22c9843418e2a991d794ffe99454baee5f802aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=8B=A0=EC=A7=80?= <101992179+ksinji@users.noreply.github.com> Date: Sun, 19 Oct 2025 18:21:03 +0900 Subject: [PATCH] =?UTF-8?q?[20251019]=20BOJ=20/=20G5=20/=20=EC=A0=84?= =?UTF-8?q?=EA=B9=83=EC=A4=84=20/=20=EA=B0=95=EC=8B=A0=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...J \354\240\204\352\271\203\354\244\204.md" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "ksinji/202510/19 BOJ \354\240\204\352\271\203\354\244\204.md" diff --git "a/ksinji/202510/19 BOJ \354\240\204\352\271\203\354\244\204.md" "b/ksinji/202510/19 BOJ \354\240\204\352\271\203\354\244\204.md" new file mode 100644 index 00000000..8658a7dc --- /dev/null +++ "b/ksinji/202510/19 BOJ \354\240\204\352\271\203\354\244\204.md" @@ -0,0 +1,47 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + static class Wire implements Comparable { + int a, b; + Wire(int a, int b) { + this.a = a; + this.b = b; + } + + @Override + public int compareTo(Wire o) { + return this.a - o.a; + } + } + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + + Wire[] arr = new Wire[N]; + int[] dp = new int[N]; + for (int i = 0; i < N; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int a = Integer.parseInt(st.nextToken()); + int b = Integer.parseInt(st.nextToken()); + arr[i] = new Wire(a, b); + } + + Arrays.sort(arr); + + int max = 1; + for (int i = 0; i < N; i++) { + dp[i] = 1; + for (int j = 0; j < i; j++) { + if (arr[i].b > arr[j].b) { + dp[i] = Math.max(dp[i], dp[j] + 1); + } + } + max = Math.max(max, dp[i]); + } +``` + System.out.println(N - max); + } +}