백준 - 1026 보물

AekT·2021년 11월 10일
post-thumbnail

백준 1026 보물

문제 : https://www.acmicpc.net/problem/1026

B를 재배열하면 안된다지만 사실 상관없다

Swift :

let t = Int(readLine()!)!
var A = readLine()!.split(separator: " ").map{Int($0)!}.sorted(by: >)
var B = readLine()!.split(separator: " ").map{Int($0)!}.sorted(by: <)
var res = 0
for i in 0..<t{
    res += A[i] * B[i]
}
print(res)
profile
으악

0개의 댓글