Skip to content

Commit 2809d49

Browse files
committed
83차 2번 문제 풀이
1 parent 068d019 commit 2809d49

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

live8/test83/문제2/박희경.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
cards = list(map(int, input().split()))
7+
m = int(input())
8+
arr = list(map(int, input().split()))
9+
10+
cards.sort() # [-10, 2, 3, 6, 10]
11+
12+
13+
def binary_search(start, end, target):
14+
while start <= end:
15+
mid = (start + end) // 2
16+
if cards[mid] == target:
17+
return True
18+
elif cards[mid] > target:
19+
end = mid - 1
20+
else:
21+
start = mid + 1
22+
23+
24+
for i in range(len(arr)):
25+
if binary_search(0, n - 1, arr[i]):
26+
arr[i] = 1
27+
else:
28+
arr[i] = 0
29+
print(*arr)

0 commit comments

Comments
 (0)