Skip to content

[Algorithm] 수 찾기 #240

@hwangJi-dev

Description

@hwangJi-dev

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

N = int(input())
nrr = list(map(int, input().split()))
M = int(input())
mrr = list(map(int, input().split()))
nrr.sort()

for i in mrr:
    left = 0
    right = N - 1
    isTarget = False

    while left <= right:
        mid = int((left + right) / 2)
        
        if nrr[mid] == i:
            isTarget = True
            break
        if nrr[mid] > i:
            right = mid - 1
        else:
            left = mid + 1
        
        mid = int(right / 2)
    
    if isTarget:
        print(1)
    else:
        print(0)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions