[Python] 백준 1026 - 보물

혜원·2023년 1월 7일
0

백준

목록 보기
21/25

백준 1026-보물

문제

코드

import sys

input = sys.stdin.readline

N = int(input())
S = 0

A = list(map(int, input().split()))
B = list(map(int, input().split()))

A.sort()

for i in range(N):
    b = max(B)
    S += A[i] * b
    B.remove(b)

print(S)

해설

  1. A에서 가장 작은수와 B에서의 가장 큰수를 곱하면 더하면 작은수가 될것이라는 아이디어로 풀었다.
profile
안녕하세요

0개의 댓글