Skip to content

Commit

Permalink
두 배열의 원소 교체 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezidayzi committed Feb 20, 2022
1 parent 3fa3fac commit 3274ee1
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
n, k = map(int, input().split())
input_a = list(map(int, input().split()))
input_b = list(map(int, input().split()))

input_a.sort()
input_b.sort(reverse=True)

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

print(sum(input_a))

0 comments on commit 3274ee1

Please sign in to comment.