From d669569a793e5e8fc32ea66afb94bdf9da329cc3 Mon Sep 17 00:00:00 2001 From: zinnnn37 <102711874+zinnnn37@users.noreply.github.com> Date: Wed, 28 Jan 2026 23:30:30 +0900 Subject: [PATCH] =?UTF-8?q?[20260128]=20BOJ=20/=20G2=20/=20=EA=B0=80?= =?UTF-8?q?=EC=9E=A5=20=EA=B8=B4=20=EC=A6=9D=EA=B0=80=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=88=98=EC=97=B4=203=20/=20=EA=B9=80?= =?UTF-8?q?=EB=AF=BC=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...353\266\204 \354\210\230\354\227\264 3.md" | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 "zinnnn37/202601/28 BOJ G2 \352\260\200\354\236\245 \352\270\264 \354\246\235\352\260\200\355\225\230\353\212\224 \353\266\200\353\266\204 \354\210\230\354\227\264 3.md" diff --git "a/zinnnn37/202601/28 BOJ G2 \352\260\200\354\236\245 \352\270\264 \354\246\235\352\260\200\355\225\230\353\212\224 \353\266\200\353\266\204 \354\210\230\354\227\264 3.md" "b/zinnnn37/202601/28 BOJ G2 \352\260\200\354\236\245 \352\270\264 \354\246\235\352\260\200\355\225\230\353\212\224 \353\266\200\353\266\204 \354\210\230\354\227\264 3.md" new file mode 100644 index 00000000..b2991f19 --- /dev/null +++ "b/zinnnn37/202601/28 BOJ G2 \352\260\200\354\236\245 \352\270\264 \354\246\235\352\260\200\355\225\230\353\212\224 \353\266\200\353\266\204 \354\210\230\354\227\264 3.md" @@ -0,0 +1,66 @@ +```java +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +public class BJ_12738_가장_긴_증가하는_부분_수열_3 { + + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static StringTokenizer st; + + private static int N; + private static int[] arr; + private static List list; + + public static void main(String[] args) throws IOException { + init(); + sol(); + } + + private static void init() throws IOException { + N = Integer.parseInt(br.readLine()); + + arr = new int[N]; + st = new StringTokenizer(br.readLine()); + for (int i = 0; i < N; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + list = new ArrayList<>(); + } + + private static void sol() throws IOException { + list.add(Integer.MIN_VALUE); + + for (int a : arr) { + int size = list.size() - 1; + + if (list.get(size) < a) { + list.add(a); + } else { + int index = binarySearch(0, size, a); + + list.set(index, a); + } + } + bw.write(list.size() - 1 + ""); + bw.flush(); + bw.close(); + br.close(); + } + + private static int binarySearch(int left, int right, int target) { + while (left < right) { + int mid = left + (right - left) / 2; + if (list.get(mid) < target) { + left = mid + 1; + } else { + right = mid; + } + } + return right; + } + +} +````