Skip to content

Commit adc6da5

Browse files
committed
[23.01.24/Python] 숫자 카드
1 parent 6514105 commit adc6da5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Python_BOJ_2023/10815.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 숫자 카드
2+
3+
n = int(input())
4+
arr1 = list(map(int, input().split()))
5+
arr1.sort()
6+
m = int(input())
7+
arr2 = list(map(int, input().split()))
8+
9+
def bin_search(target):
10+
global n, m, arr1
11+
start, end = 0, n - 1
12+
13+
while start <= end:
14+
mid = (start + end) // 2
15+
if arr1[mid] == target:
16+
return True
17+
18+
if arr1[mid] < target:
19+
start = mid + 1
20+
elif arr1[mid] > target:
21+
end = mid - 1
22+
return False
23+
24+
for i in range(m):
25+
if bin_search(arr2[i]):
26+
print(1)
27+
else:
28+
print(0)

0 commit comments

Comments
 (0)