[백준 10815번][Python/파이썬] 숫자 카드

공학도 Lee·2023년 2월 8일
0

백준 문제 풀이

목록 보기
27/63

1. 문제


출처: 백준 10815번 숫자 카드

2. 풀이


숫자 카드의 최대, 최솟값이 10,000,00010,000,00010,000,000-10,000,000으로 주어져 있으므로, 카운팅 정렬을 하는 것처럼 문제를 접근하면 된다.

위의 값들을 바탕으로 숫자 카드 있는지 없는지 저장하는 리스트를 만들고, 검사를 진행하면 된다.

3. 소스코드


N = int(input())
cards = list(map(int,input().split()))
M = int(input())
numbers = list(map(int,input().split()))

max_num = 10000000
checked = [0]*(max_num*2+1)

for i in range(N):
    checked[cards[i]+max_num] = 1
for j in range(M):
    print(checked[numbers[j]+max_num],end=" ")

4. 그 외


profile
이창민, Changmin Lee

0개의 댓글