20250923 baekjoon
This commit is contained in:
parent
0538a8d869
commit
8d2b68a134
16
code_study/Baekjoon/swift/1026.swift
Normal file
16
code_study/Baekjoon/swift/1026.swift
Normal 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)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user