백준 10816. 숫자카드2


백준 10816. 숫자카드2

import sys from collections import Counter input = sys.stdin.readline n = int(input()) card = list(map(int,input().split())) m = int(input()) test = list(map(int,input().split())) count = Counter(card) for i in range(len(test)): if test[i] in count: print(count[test[i]], end=' ') else: print(0, end=' ') 시간초과를 줄이기 위한 팁 input() -> sy.stdin.readline() 사용하기 count()-> Counter() 사용하기 : Counter은 빈도수를 딕셔너리 형태로 만듬 Counter({10: 3, 3: 2, -10: 2, 6: 1, 2: 1, 7: 1}) 이렇게 뜨게 해줌 이진탐색 문제라고 해서 이진탐색으로 풀려고했는데 시간초과떠...



원문링크 : 백준 10816. 숫자카드2