Scroll indicator done
728x90

https://www.acmicpc.net/problem/1920


from sys import stdin, stdout

n = int(stdin.readline())
arr1 = list(map(int, input().split()))
arr1.sort()
m = int(sys.stdin.readline())
arr2 = list(map(int, input().split()))

for i in arr2:
    start = 0
    end = n-1
    target = i
    ans = 0
    while start <= end:
        mid = (start+end)//2
        if arr1[mid] == target:
            ans = 1
            break
        elif target < arr1[mid]:
            end = mid-1
        else:
            start = mid+1
    print(ans)

 

728x90

'BAEKJOON > Python' 카테고리의 다른 글

[B10886][덱][python]  (0) 2021.03.18
[B1978][소수 찾기][python]  (0) 2021.03.18
[B10828][스택][python]  (0) 2021.03.17
[B9012][괄호][python]  (0) 2021.03.16
[B10816][숫자 카드 2][python]  (0) 2021.03.15