요새 비슷한 문제 너무 많이 풀었다. 매칭문제. 투포인터로 매칭
for test in range(1, int(input()) + 1):
N, M = map(int, input().split())
w = list(map(int, input().split()))
t = list(map(int, input().split()))
t.sort(reverse=True)
w.sort(reverse=True)
answer = 0
left = 0
for truck in t:
while left < N and truck < w[left]:
left += 1
if left == N: break
answer += w[left]
left += 1
print(f'#{test} {answer}')
'practivceAlgorithm > swexpertacademy' 카테고리의 다른 글
[SWEA][Python] 5203 베이비진 게임 (0) | 2021.09.28 |
---|---|
[SWEA][Python] 5202 화물도크 (0) | 2021.09.28 |
[SWEA][Python] 5189 전자카트 (0) | 2021.09.28 |
[SWEA][Python] 5188 최소합 (0) | 2021.09.28 |
[SWEA][Python] 10966 물놀이를 가자 (1) | 2021.09.24 |