004 컴퓨터과학/알고리즘
[백준 온라인저지] 이진 탐색 / 10816. 숫자 카드 2
Dallas
2023. 6. 6. 10:51
반응형
문제
예제
소스코드
시간 : 1500ms
from bisect import bisect_left, bisect_right
n = int(input())
numbers = list(map(int, input().split(' ')))
m = int(input())
targets = list(map(int, input().split(' ')))
numbers.sort()
def bisect_num(arr, target) :
x = bisect_right(arr, target)
y = bisect_left(arr, target)
return x - y
arr = [bisect_num(numbers, x) for x in targets]
for x in arr :
print(x, end=' ')
반응형