[알고리즘/백준] 1026번 : 보물(python)

유현민·2022년 2월 18일
0

알고리즘

목록 보기
8/253

정말 간단하게 풀었다. a를 미리 정렬하고 for 문으로 a를 하나씩 꺼내온다. b는 가장 큰 것만 가져와서 곱해주고 결과에 더한 후 곱했던 수를 remove로 삭제한다

n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
tot = 0
for i in a:
    tot += max(b) * i
    b.remove(max(b))
print(tot)
profile
smilegate megaport infra

0개의 댓글