Bibi's DevLog πŸ€“πŸŽ

[λ°±μ€€ 2953] λ‚˜λŠ” μš”λ¦¬μ‚¬λ‹€ (Swift) λ³Έλ¬Έ

ν”„λ‘œκ·Έλž˜λ°/μ•Œκ³ λ¦¬μ¦˜ 풀이 Swift

[λ°±μ€€ 2953] λ‚˜λŠ” μš”λ¦¬μ‚¬λ‹€ (Swift)

λΉ„λΉ„ bibi 2022. 9. 29. 12:08

https://www.acmicpc.net/problem/2953

 

2953번: λ‚˜λŠ” μš”λ¦¬μ‚¬λ‹€

"λ‚˜λŠ” μš”λ¦¬μ‚¬λ‹€"λŠ” λ‹€μ„― μ°Έκ°€μžλ“€μ΄ μ„œλ‘œμ˜ μš”λ¦¬ μ‹€λ ₯을 λ½λ‚΄λŠ” ν‹°λΉ„ ν”„λ‘œμ΄λ‹€. 각 μ°Έκ°€μžλŠ” μžμ‹ μžˆλŠ” μŒμ‹μ„ ν•˜λ‚˜μ”© λ§Œλ“€μ–΄μ˜€κ³ , μ„œλ‘œ λ‹€λ₯Έ μ‚¬λžŒμ˜ μŒμ‹μ„ 점수둜 평가해쀀닀. μ μˆ˜λŠ” 1점뢀터 5

www.acmicpc.net

 

각 쀄에 μ£Όμ–΄μ§„μˆ«μžλ₯Ό ν•©ν•˜κ³ , κ°€μž₯ 큰 μ μˆ˜μ™€ κ·Έ 점수의 번호λ₯Ό 좜λ ₯ν•œλ‹€.

풀이

var num = 0
var score = 0
(1...5).forEach { number in
    let inputSum = readLine()!.split(separator: " ").map { Int($0)! }.reduce(0, +)
    if inputSum > score {
        score = inputSum
        num = number
    }
}
print(num, score)