1026. 보물
- 내 풀이
- b를 재배열 할 수 없다고 했지만 구해야하는 값은 최솟값이기때문에 배열해도 상관없어서 sort써서 계산
n = int(input())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
alist.sort(reverse=True)
blist.sort()
s = 0
for a, b in zip(alist, blist):
s += a*b
print(s)
- 혹시나 하고 찾아보니 재배열을 하지않고 풀어야했다
- 두 리스트에서 min(a) *max(b) 를 뽑아내서 곱해주기
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
s = 0
for i in range(n):
s += min(a_list) * max(b_list)
a_list.pop(a_list.index(min(a_list)))
b_list.pop(b_list.index(max(b_list)))
print(s)