20250923 baekjoon

This commit is contained in:
songyc macbook 2025-09-23 21:49:29 +09:00
parent 0538a8d869
commit 8d2b68a134

View File

@ -0,0 +1,16 @@
if let N = Int(readLine() ?? ""),
let input1 = readLine(), let input2 = readLine(),
let A = input1.split(separator: " ").compactMap({Int($0)}) as? [Int],
let B = input2.split(separator: " ").compactMap({Int($0)}) as? [Int],
A.count == N, B.count == N
{
let sortedA = A.sorted()
let sortedB = B.sorted(by: >)
var result: Int = 0
for i in 0..<N {
result += sortedA[i] * sortedB[i]
}
print(result)
}