본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 7795번 먹을 것인가 먹힐 것인가

by 현장 2022. 5. 6.

-Code

from bisect import bisect_left

t = int(input())

for _ in range(t):
    cnt = 0
    n, m = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())))
    for i in a:
        cnt += bisect_left(b, i)
    print(cnt)

파이썬 라이브러리 중 이분 탐색 관련 라이브러리가 있어서 사용해 보았습니다.