[SWEA] 5201 컨테이너 운반

김은서·2021년 10월 6일
0

SWEA

목록 보기
44/47

Python Code

T = int(input())
for tc in range(1, T+1):
    N, M = map(int, input().split())
    box = list(map(int, input().split()))
    truck = list(map(int, input().split()))
    box.sort()
    box.reverse()
    total = 0
    for i in range(len(truck)):
        for j in range(len(box)):
            if truck[i] >= box[j]:
                total += box[j]
                box.remove(box[j])
                break
    print('#{} {}'.format(tc, total))
profile
Gracelog

0개의 댓글