Skip to content

Commit 74d35e4

Browse files
authored
[BOJ] 1920 수 찾기 (S4)
1 parent 58d9e53 commit 74d35e4

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

김지호/8주차/260220.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# https://www.acmicpc.net/problem/1920
2+
# 수 찾기, 실버4
3+
4+
import sys
5+
sys.stdin = open('../../../input.txt', 'r')
6+
7+
N = int(input().strip())
8+
numbers = list(map(int, input().strip().split()))
9+
M = int(input().strip())
10+
targets = list(map(int, input().strip().split()))
11+
12+
numbers.sort()
13+
14+
for target in targets:
15+
left, right = 0, N - 1
16+
found = False
17+
18+
while left <= right:
19+
mid = (left + right) // 2
20+
21+
if target == numbers[mid]:
22+
found = True
23+
print(1)
24+
break
25+
elif target > numbers[mid]:
26+
left = mid + 1
27+
else:
28+
right = mid - 1
29+
30+
if not found:
31+
print(0)

0 commit comments

Comments
 (0)