Skip to content

Commit bf9218d

Browse files
committed
[BOJ] #1920. 수 찾기 / 실버4 / 30분 / 성공
1 parent c387e77 commit bf9218d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
n = int(input())
2+
origin = [int(n) for n in input().split()] # 4,1,5,2,3
3+
m = int(input())
4+
compare = [int(m) for m in input().split()] # 1,3,7,9,5
5+
6+
origin.sort() # 1,2,3,4,5
7+
8+
for i in range(m): #
9+
tag = False
10+
low = 0
11+
high = len(origin) - 1
12+
target = compare[i] # 5
13+
while low <= high:
14+
mid = (low + high) // 2
15+
if origin[mid] == target:
16+
tag = True
17+
print(1)
18+
break
19+
elif origin[mid] > target:
20+
high = mid - 1
21+
else:
22+
low = mid + 1
23+
24+
if tag is False:
25+
print(0)

0 commit comments

Comments
 (0)