What I Learned/Algorithm Practice
[백준 - python] 10815번: 숫자 카드
Interrobang
2022. 11. 30. 17:25
문제 링크
10815번: 숫자 카드
첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. 숫자 카드에 적혀있는 수는 -10,000,000보다 크거나 같고, 10,
www.acmicpc.net
문제 풀이
import sys
N = int(sys.stdin.readline())
card_list = list(map(int, sys.stdin.readline().split()))
M = int(sys.stdin.readline())
check_list = list(map(int, sys.stdin.readline().split()))
card_dict = {}
for i in range(len(card_list)):
card_dict[card_list[i]] = 0
for j in range(M):
if check_list[j] not in card_dict:
print(0, end=' ')
else:
print(1, end=' ')
*key point: 딕셔너리와 for문을 이용하여 입력값을 상근이가 가지고 있는지 판별한다.