๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“– Problem Solution

[Swift] Baekjoon ์ตœ๋Œ“๊ฐ’ 2562๋ฒˆ

by Fomagran ๐Ÿ’ป 2022. 1. 6.
728x90
๋ฐ˜์‘ํ˜•

 

Problem

 

 

2562๋ฒˆ: ์ตœ๋Œ“๊ฐ’

9๊ฐœ์˜ ์„œ๋กœ ๋‹ค๋ฅธ ์ž์—ฐ์ˆ˜๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ, ์ด๋“ค ์ค‘ ์ตœ๋Œ“๊ฐ’์„ ์ฐพ๊ณ  ๊ทธ ์ตœ๋Œ“๊ฐ’์ด ๋ช‡ ๋ฒˆ์งธ ์ˆ˜์ธ์ง€๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์„œ๋กœ ๋‹ค๋ฅธ 9๊ฐœ์˜ ์ž์—ฐ์ˆ˜ 3, 29, 38, 12, 57, 74, 40, 85, 61 ์ด ์ฃผ์–ด

www.acmicpc.net


Solution

 

1. ์ˆซ์ž๋ฅผ ์ž…๋ ฅ ๋ฐ›์œผ๋ฉฐ ์ตœ๋Œ“๊ฐ’์„ ๊ฐฑ์‹ ํ•œ๋‹ค.

 

var count:Int = 0
var max = (0,0)

while count < 9 {
    let n = Int(readLine() ?? "") ?? 0
    count += 1
    if max.1 < n {
        max = (count,n)
    }
}

 

2. ์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ๋Œ“๊ฐ’์ด ๋ช‡ ๋ฒˆ์งธ์ธ์ง€ ์ถœ๋ ฅํ•œ๋‹ค.

 

print(max.1)
print(max.0)

Source Code

 

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€