본문 바로가기
Python/이것이 취업을 위한 코딩 테스트다(with 파이썬)

이것이 취업을 위한 코딩테스트다 - 두 배열의 원소 교체

by sophia02 2022. 7. 3.
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a.sort()
b.sort(reverse=True)

for i in range(k):
    if a[i] < b[i]:
        a[i], b[i] = b[i], a[i]
    else:
        break

print(sum(a))