We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1c005d9 commit 6514105Copy full SHA for 6514105
Python_BOJ_2023/1920.py
@@ -0,0 +1,32 @@
1
+# 수 찾기
2
+
3
+n = int(input())
4
+arr1 = list(map(int, input().split()))
5
+arr1.sort()
6
7
+m = int(input())
8
+arr2 = list(map(int, input().split()))
9
10
+def binary_search(num):
11
+ global arr1
12
+ start = 0
13
+ end = len(arr1) - 1
14
15
+ while start <= end:
16
+ mid = (start + end) // 2
17
+ if arr1[mid] == num:
18
+ return True
19
20
+ if arr1[mid] < num:
21
+ start = mid + 1
22
+ elif arr1[mid] > num:
23
+ end = mid - 1
24
25
+ return False
26
27
28
+for i in arr2:
29
+ if binary_search(i):
30
+ print(1)
31
+ else:
32
+ print(0)
0 commit comments