Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Algorithm] 수 찾기 #240

Open
hwangJi-dev opened this issue May 12, 2023 · 0 comments
Open

[Algorithm] 수 찾기 #240

hwangJi-dev opened this issue May 12, 2023 · 0 comments
Assignees
Labels

Comments

@hwangJi-dev
Copy link
Owner

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)
@hwangJi-dev hwangJi-dev self-assigned this May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant