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

[๋ฐฑ์ค€ 9501] ๊ฟ์˜ ์šฐ์ฃผ์—ฌํ–‰ (Swift) ๋ณธ๋ฌธ

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

[๋ฐฑ์ค€ 9501] ๊ฟ์˜ ์šฐ์ฃผ์—ฌํ–‰ (Swift)

๋น„๋น„ bibi 2022. 12. 12. 22:21

9501๋ฒˆ: ๊ฟ์˜ ์šฐ์ฃผ์—ฌํ–‰

  • ์šฐ์ฃผ์„ ์ด ๋‚  ์ˆ˜ ์žˆ๋Š” ๊ฑฐ๋ฆฌ = ์šฐ์ฃผ์„ ์˜ ์ตœ๊ณ ์†๋„ * (์šฐ์ฃผ์„ ์˜ ์—ฐ๋ฃŒ์–‘ / ์šฐ์ฃผ์„ ์˜ ์—ฐ๋ฃŒ์†Œ๋น„์œจ)
  • ์šฐ์ฃผ์„ ์ด ๋‚  ์ˆ˜ ์žˆ๋Š” ๊ฑฐ๋ฆฌ๊ฐ€ ๋ชฉ์ ์ง€๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ๋ณด๋‹ค ๊ธธ๊ฑฐ๋‚˜ ๊ฐ™๋‹ค๋ฉด ๋ชฉ์ ์ง€๊นŒ์ง€ ๊ฐˆ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ๋‹ต์— +1์„ ํ•˜๋ฉด ๋œ๋‹ค.
  • ์ด ๋•Œ Int๋ผ๋ฆฌ ๋‚˜๋ˆ„๋ฉด ์†Œ์ˆ˜์  ์ดํ•˜ ๊ฐ’์„ ๋ฒ„๋ฆฌ๋ฏ€๋กœ, Double๋ผ๋ฆฌ ๋‚˜๋ˆ„์–ด ํŒ๋‹จํ•ด์•ผ ์ •ํ™•ํ•œ ๊ฒฐ๊ณผ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.

ํ’€์ด

let count = Int(readLine()!)!
(1...count).forEach { _ in
    let inputArr = readLine()!.split(separator: " ").map { Int($0)! }
    let spaceshipCount = inputArr[0]
    let distance = inputArr[1]
    var answer = 0
    (1...spaceshipCount).forEach { num in
        let spaceshipArr = readLine()!.split(separator: " ").map { Double($0)! }
        let move = spaceshipArr[0] * (spaceshipArr[1] / spaceshipArr[2])
        if Double(distance) <= move {
            answer += 1
        }
    }
    print(answer)
}