๋ฐ์ํ
import Foundation
/// N : ATM์์ ์ค ์ ์๋ ์ฌ๋ ์
/// P : i๋ฒ์งธ ์ฌ๋์ด ๋์ ์ธ์ถํ๋๋ฐ ๊ฑธ๋ฆฌ๋ ์๊ฐ
let N = Int(readLine()!)!
var Ps = readLine()!.components(separatedBy: " ").map { Int($0)! }
Ps.sort()
var sum = 0
var result = 0
for Pi in Ps {
sum += Pi
result += sum
}
print(result)
๋ฐ์ํ
'๐ ์ฝํ > BOJ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] ๋ฐฑ์ค 9095 1, 2, 3 ๋ํ๊ธฐ (0) | 2023.04.14 |
---|---|
[Swift] ๋ฐฑ์ค 10026 ์ ๋ก์์ฝ (0) | 2023.04.14 |
[Swift] ๋ฐฑ์ค2178 ๋ฏธ๋กํ์ (0) | 2023.04.12 |
[Swift] ๋ฐฑ์ค2606 ๋ฐ์ด๋ฌ์ค (0) | 2023.04.12 |
[Swift] ๋ฐฑ์ค 1927 ์ต์ ํ (0) | 2023.04.11 |