From 8ecbc1730062297314b6deb242f358791984c7a7 Mon Sep 17 00:00:00 2001 From: longrunpc Date: Wed, 8 Apr 2026 03:17:42 +0900 Subject: [PATCH] =?UTF-8?q?Solve(binary=5Fsearch):=20BOJ=2011722=20"?= =?UTF-8?q?=EA=B0=80=EC=9E=A5=20=EA=B8=B4=20=EA=B0=90=EC=86=8C=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=B6=80=EB=B6=84=20=EC=88=98=EC=97=B4"=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- boj/solved/binary_search/11722/Main.java | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 boj/solved/binary_search/11722/Main.java diff --git a/boj/solved/binary_search/11722/Main.java b/boj/solved/binary_search/11722/Main.java new file mode 100644 index 0000000..4917cc1 --- /dev/null +++ b/boj/solved/binary_search/11722/Main.java @@ -0,0 +1,44 @@ +import java.io.*; +import java.util.*; + +class Main { + static int n; + static int[] arr; + static List res = new ArrayList<>(); + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + n = Integer.parseInt(br.readLine()); + StringTokenizer st = new StringTokenizer(br.readLine()); + + arr = new int[n]; + res.add(arr[0]); + for(int i = 0;i tmp) { + res.add(tmp); + } + else { + res.set(binarySearch(tmp), tmp); + } + } + + System.out.println(res.size()); + } + + public static int binarySearch(int num) { + int l = 0; + int r = res.size()-1; + int pointIdx = res.size()-1; + while(l <= r) { + int mid = (l + r) / 2; + if (res.get(mid) > num) { + l = mid +1; + } + else { + r = mid - 1; + pointIdx = Math.min(pointIdx, mid); + } + } + return pointIdx; + } +} \ No newline at end of file