반응형
문제
예제
소스코드
시간 : 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=' ')
반응형
'004 컴퓨터과학 > 알고리즘' 카테고리의 다른 글
[백준 온라인저지] 1764. 듣보잡 (0) | 2023.06.06 |
---|---|
[백준 온라인저지] 이진 탐색 / 2805. 나무 자르기 (0) | 2023.06.06 |
[백준 온라인저지] 1157. 단어 공부 (0) | 2023.06.04 |
[백준 온라인저지] 그리디 알고리즘 / 5585. 거스름돈 (0) | 2023.06.04 |
[백준 온라인저지] 그리디 / 2839. 설탕 배달 (0) | 2023.06.04 |
댓글