From 2020c850d8bb26c0ff33366f6566b979f4a30881 Mon Sep 17 00:00:00 2001 From: Gyuhyeok99 Date: Thu, 1 Jan 2026 18:18:03 +0900 Subject: [PATCH] =?UTF-8?q?[Week01]=20BOJ=201920:=20=EC=88=98=20=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gyuhyeok99.cpp" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "weekly/week01/BOJ_1920_\354\210\230 \354\260\276\352\270\260/gyuhyeok99.cpp" diff --git "a/weekly/week01/BOJ_1920_\354\210\230 \354\260\276\352\270\260/gyuhyeok99.cpp" "b/weekly/week01/BOJ_1920_\354\210\230 \354\260\276\352\270\260/gyuhyeok99.cpp" new file mode 100644 index 0000000..bf31637 --- /dev/null +++ "b/weekly/week01/BOJ_1920_\354\210\230 \354\260\276\352\270\260/gyuhyeok99.cpp" @@ -0,0 +1,44 @@ +#include +#include +using namespace std; + +int n, m, num; +int a[100001]; + +bool find(int num, int l, int r) { + while(l <= r) { + int mid = (l + r) / 2; + if(num == a[mid]) { + return true; + } + else if(num > a[mid]) { + l = mid + 1; + } + else { + r = mid - 1; + } + } + return false; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); cout.tie(NULL); + + cin >> n; + for(int i = 0; i < n; i++) { + cin >> a[i]; + } + sort(a, a + n); + cin >> m; + for(int i = 0; i < m; i++) { + cin >> num; + if(find(num, 0, n - 1)) { + cout << 1 << '\n'; + } + else { + cout << 0 << '\n'; + } + } + return 0; +}