Bibi's DevLog ๐Ÿค“๐ŸŽ

[๋ฐฑ์ค€ 2476] ์ฃผ์‚ฌ์œ„ ๊ฒŒ์ž„ (Swift) ๋ณธ๋ฌธ

ํ”„๋กœ๊ทธ๋ž˜๋ฐ/์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ’€์ด Swift

[๋ฐฑ์ค€ 2476] ์ฃผ์‚ฌ์œ„ ๊ฒŒ์ž„ (Swift)

๋น„๋น„ bibi 2022. 9. 9. 21:21

2476๋ฒˆ: ์ฃผ์‚ฌ์œ„ ๊ฒŒ์ž„

  • ์„ธ ์ฃผ์‚ฌ์œ„์˜ ๋ˆˆ ์ค‘์— ๊ฐ™์€ ๋ˆˆ์ด ๋ฌด์—‡์ธ์ง€ ์ฐพ์•„๋‚ด๋Š” ๊ฒƒ์ด ๊ด€๊ฑด์ด์—ˆ๋˜ ๋ฌธ์ œ.
  • 3๊ฐœ๊ฐ€ ๊ฐ™์„ ๋•Œ, ๋ชจ๋‘ ๋‹ค๋ฅผ ๋•Œ๋Š” ์กฐ๊ฑด๋ฌธ์œผ๋กœ ์–ด๋ ต์ง€ ์•Š๊ฒŒ ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ
  • ๋ฌธ์ œ๋Š” 2๊ฐœ๊ฐ€ ๊ฐ™์„ ๋•Œ์ธ๋ฐ
    • ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์ด ์žˆ์„ ๊ฑฐ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ์ง€๋งŒ ๋‚ด๊ฐ€ ์ƒ๊ฐํ•œ ๋ฐฉ๋ฒ•์€ ์ฒซ ๋ฒˆ์งธ ์›์†Œ๋ฅผ ๊ณจ๋ผ ๊ทธ ์›์†Œ์™€ ๊ฐ™์€ ์›์†Œ์˜ ๊ฐฏ์ˆ˜๊ฐ€ 2๊ฐœ์ด๋ฉด ์ฒซ ๋ฒˆ์งธ ์›์†Œ๋ฅผ, ๊ทธ๋ ‡์ œ ์•Š์œผ๋ฉด ๋งˆ์ง€๋ง‰ ์›์†Œ๋ฅผ ๊ฐ™์€ ๋ˆˆ์œผ๋กœ ์ •ํ–ˆ๋‹ค.
    • 2๊ฐœ์˜ ๋ˆˆ์ด ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” 3๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค : aab, aba, baa
    • ์ฒซ ๋ฒˆ์งธ ์›์†Œ๊ฐ€ 2๊ฐœ์˜ ๊ฐ™์€ ๋ˆˆ์— ํฌํ•จ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด(aab๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด), ๋‚˜๋จธ์ง€ ๊ฒฝ์šฐ๋ฅผ ๋ณด์•˜์„ ๋•Œ ๋ฐ˜๋“œ์‹œ ์„ธ ๋ฒˆ์งธ ์›์†Œ๊ฐ€ 2๊ฐœ์˜ ๊ฐ™์€ ๋ˆˆ์— ํ•ด๋‹น๋˜๊ฒŒ ๋œ๋‹ค (aba, baa)
  • ๊ฐ€์žฅ ํฐ ์ƒ๊ธˆ์„ ์ฐพ๋Š” ๊ฒƒ์€ ๋ฐ˜๋ณต๋ฌธ ๋ฐ”๊นฅ์— ์ƒ๊ธˆ ๋ณ€์ˆ˜๋ฅผ ๋‘๊ณ , ์ด๋ฒˆ ํšŒ์ฐจ์— ๊ณ„์‚ฐํ•œ ์ƒ๊ธˆ์ด ๊ธฐ์กด ์ƒ๊ธˆ๋ณด๋‹ค ํด ๋•Œ ๋Œ€์ฒดํ•˜๋„๋ก ํ–ˆ๋‹ค.

ํ’€์ด

let count = Int(readLine()!)!
var answer = 0
(1...count).forEach { _ in
    let inputArr = readLine()!.split(separator: " ").map { Int($0)! }
    let a = inputArr[0]
    let b = inputArr[1]
    let c = inputArr[2]
    var prize = 0
    if a == b && b == c && a == c {
        prize = 10000 + (a * 1000)
    } else if a == b || b == c || a == c {
        var equalNum = 0
        if inputArr.filter({ $0 == a }).count == 2 {
            equalNum = a
        } else {
            equalNum = c
        }
        prize = 1000 + equalNum * 100
    } else {
        prize = inputArr.max()! * 100
    }
    if prize > answer {
        answer = prize
    }
}
print(answer)