ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Kotlin ๐Ÿฌ ๋ฐฑ์ค€ 6๋‹จ๊ณ„ :: 25206 ๋ฒˆ
    2023. 5. 2. 16:56
    ๋ฐ˜์‘ํ˜•

    ๋„ˆ์˜ ํ‰์ ์€

    ๋ฌธ์ œ   |

      ์ธํ•˜๋Œ€ํ•™๊ต ์ปดํ“จํ„ฐ๊ณตํ•™๊ณผ๋ฅผ ์กธ์—…ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”, ์ „๊ณตํ‰์ ์ด 3.3 ์ด์ƒ์ด๊ฑฐ๋‚˜ ์กธ์—…๊ณ ์‚ฌ๋ฅผ ํ†ต๊ณผํ•ด์•ผ ํ•œ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์•„๋ฟ”์‹ธ, ์น˜ํ›ˆ์ด๋Š” ๊นœ๋นกํ•˜๊ณ  ์กธ์—…๊ณ ์‚ฌ๋ฅผ ์‘์‹œํ•˜์ง€ ์•Š์•˜๋‹ค๋Š” ์‚ฌ์‹ค์„ ๊นจ๋‹ฌ์•˜๋‹ค!

      ์น˜ํ›ˆ์ด์˜ ์ „๊ณตํ‰์ ์„ ๊ณ„์‚ฐํ•ด์ฃผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•ด๋ณด์ž.

      ์ „๊ณตํ‰์ ์€ ์ „๊ณต๊ณผ๋ชฉ๋ณ„ (ํ•™์  × ๊ณผ๋ชฉํ‰์ )์˜ ํ•ฉ์„ ํ•™์ ์˜ ์ดํ•ฉ์œผ๋กœ ๋‚˜๋ˆˆ ๊ฐ’์ด๋‹ค.

      ์ธํ•˜๋Œ€ํ•™๊ต ์ปดํ“จํ„ฐ๊ณตํ•™๊ณผ์˜ ๋“ฑ๊ธ‰์— ๋”ฐ๋ฅธ ๊ณผ๋ชฉํ‰์ ์€ ๋‹ค์Œ ํ‘œ์™€ ๊ฐ™๋‹ค.

      P/F ๊ณผ๋ชฉ์˜ ๊ฒฝ์šฐ ๋“ฑ๊ธ‰์ด P๋˜๋Š” F๋กœ ํ‘œ์‹œ๋˜๋Š”๋ฐ, ๋“ฑ๊ธ‰์ด P์ธ ๊ณผ๋ชฉ์€ ๊ณ„์‚ฐ์—์„œ ์ œ์™ธํ•ด์•ผ ํ•œ๋‹ค.

      ๊ณผ์—ฐ ์น˜ํ›ˆ์ด๋Š” ๋ฌด์‚ฌํžˆ ์กธ์—…ํ•  ์ˆ˜ ์žˆ์„๊นŒ?

     

    ์ž…๋ ฅ   |

      20์ค„์— ๊ฑธ์ณ ์น˜ํ›ˆ์ด๊ฐ€ ์ˆ˜๊ฐ•ํ•œ ์ „๊ณต๊ณผ๋ชฉ์˜ ๊ณผ๋ชฉ๋ช…, ํ•™์ , ๋“ฑ๊ธ‰์ด ๊ณต๋ฐฑ์œผ๋กœ ๊ตฌ๋ถ„๋˜์–ด ์ฃผ์–ด์ง„๋‹ค.

     

    ์ถœ๋ ฅ   |

      ์น˜ํ›ˆ์ด์˜ ์ „๊ณตํ‰์ ์„ ์ถœ๋ ฅํ•œ๋‹ค.

      ์ •๋‹ต๊ณผ์˜ ์ ˆ๋Œ€์˜ค์ฐจ ๋˜๋Š” ์ƒ๋Œ€์˜ค์ฐจ๊ฐ€  ์ดํ•˜์ด๋ฉด ์ •๋‹ต์œผ๋กœ ์ธ์ •ํ•œ๋‹ค.

     

    ์ œํ•œ   |

    • 1 ≤ ๊ณผ๋ชฉ๋ช…์˜ ๊ธธ์ด ≤ 50
    • ๊ณผ๋ชฉ๋ช…์€ ์•ŒํŒŒ๋ฒณ ๋Œ€์†Œ๋ฌธ์ž ๋˜๋Š” ์ˆซ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ, ๋„์–ด์“ฐ๊ธฐ ์—†์ด ์ฃผ์–ด์ง„๋‹ค. ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง€๋Š” ๋ชจ๋“  ๊ณผ๋ชฉ๋ช…์€ ์„œ๋กœ ๋‹ค๋ฅด๋‹ค.
    • ํ•™์ ์€ 1.0, 2.0, 3.0, 4.0 ์ค‘ ํ•˜๋‚˜์ด๋‹ค.
    • ๋“ฑ๊ธ‰์€ A+, A0, B+, B0, C+, C0, D+, D0, F, P์ค‘ ํ•˜๋‚˜์ด๋‹ค.
    • ์ ์–ด๋„ ํ•œ ๊ณผ๋ชฉ์€ ๋“ฑ๊ธ‰์ด P๊ฐ€ ์•„๋‹˜์ด ๋ณด์žฅ๋œ๋‹ค.

     

     

    ํ’€์ด  |

      ํ•™์ ํ‘œ๋ฅผ map์„ ์ด์šฉํ•ด key, value๋ฅผ ๋งค์นญ์‹œํ‚จ๋‹ค.

      ์ž…๋ ฅ๊ฐ’์„ ๋ฐ›์•„ ํ•™์ ํ‘œ์—์„œ ์ž…๋ ฅ๊ฐ’์˜ ๋“ฑ๊ธ‰์— ํ•ด๋‹นํ•˜๋Š” ๊ณผ๋ชฉํ‰์ ๊ณผ ์ž…๋ ฅ๊ฐ’์˜ ํ•™์ ์„ ์ด์šฉํ•ด (ํ•™์  × ๊ณผ๋ชฉํ‰์ )์˜ ํ•ฉ / ํ•™์ ์˜ ์ดํ•ฉ ๊ฐ’์„ ๊ตฌํ•œ๋‹ค.

     

     

    ๋‹ต์•ˆ  |

    fun main() {
        val scoreMap: Map<String, Double> = mapOf(
            "A+" to 4.5,
            "A0" to 4.0,
            "B+" to 3.5,
            "B0" to 3.0,
            "C+" to 2.5,
            "C0" to 2.0,
            "D+" to 1.5,
            "D0" to 1.0,
            "F" to 0.0,
        )
        
        var total: Double = 0.0
        var totalScore: Double = 0.0
        
        for(i in 0 until 20) {
            val info: String = readLine()!!
            val infoList = info.split(" ")
            val score: Double = infoList[1].toDouble()
            val grade: String = infoList[2]
    
            if(grade.equals("P")) continue
            total += scoreMap.get(grade)!! * score
            totalScore += score
        }
        
        print(total / totalScore)
    }
    ๋ฐ˜์‘ํ˜•

    ๋Œ“๊ธ€

Designed by Tistory.