From c5b508f0b39368dcebc34e542d15478302526b26 Mon Sep 17 00:00:00 2001 From: llIllIllIllIllIllIllIllI <_@seol.pro> Date: Fri, 12 Dec 2025 23:57:41 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Create=2012=20BOJ=20G2=20=EA=BC=AC=EC=9D=B8?= =?UTF-8?q?=20=EC=A0=84=EA=B9=83=EC=A4=84.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \354\240\204\352\271\203\354\244\204.md" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "Seol-JY/202512/12 BOJ G2 \352\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" diff --git "a/Seol-JY/202512/12 BOJ G2 \352\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" "b/Seol-JY/202512/12 BOJ G2 \352\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" new file mode 100644 index 00000000..bf9f15a6 --- /dev/null +++ "b/Seol-JY/202512/12 BOJ G2 \352\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" @@ -0,0 +1,32 @@ +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine().trim()); + + int[] arr = new int[n]; + StringTokenizer st = new StringTokenizer(br.readLine()); + + for (int i = 0; i < n; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + + // LIS using binary search + ArrayList lis = new ArrayList<>(); + + for (int a : arr) { + int pos = Collections.binarySearch(lis, a); + if (pos < 0) pos = -(pos + 1); + + if (pos == lis.size()) { + lis.add(a); + } else { + lis.set(pos, a); + } + } + + System.out.println(n - lis.size()); + } +} From 3bfe7f2b12187bbf7c7bf3073bd3978694af773c Mon Sep 17 00:00:00 2001 From: llIllIllIllIllIllIllIllI <_@seol.pro> Date: Sat, 13 Dec 2025 00:04:29 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[20251212]=20BOJ=20/=20G2=20/=20=EA=BC=AC?= =?UTF-8?q?=EC=9D=B8=20=EC=A0=84=EA=B9=83=EC=A4=84=20/=20=EC=84=A4?= =?UTF-8?q?=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" | 1 - 1 file changed, 1 deletion(-) diff --git "a/Seol-JY/202512/12 BOJ G2 \352\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" "b/Seol-JY/202512/12 BOJ G2 \352\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" index bf9f15a6..b39a5b59 100644 --- "a/Seol-JY/202512/12 BOJ G2 \352\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" +++ "b/Seol-JY/202512/12 BOJ G2 \352\274\254\354\235\270 \354\240\204\352\271\203\354\244\204.md" @@ -13,7 +13,6 @@ public class Main { arr[i] = Integer.parseInt(st.nextToken()); } - // LIS using binary search ArrayList lis = new ArrayList<>(); for (int a : arr) {