알고리즘 문제 풀이/백준

[Algorithm] 백준 - 평균 (1546) (Kotlin)

참깨빵위에참깨빵_ 2023. 1. 13. 18:28
728x90
반응형

 

fun main() {
    val count = readln().toInt()
    val grade = readln().split(" ")
    val list = arrayListOf<Int>()
    for (i in grade) {
        list.add(i.toInt())
    }
    val max = list.max()
    var result = 0.0
    for (i in list) {
        result += (i.toDouble() / max.toDouble()) * 100
    }
    println((result / count))
}

 

반응형