import kotlin.math.ceil fun main() { val (n,f) = readln().split(" ").map { it.toInt() } val values = readln().split(" ").map { it.toDouble() } val start = 1.0 val end = f.toDouble() var step = (end-start) / 2 var current = start + step if(current < start) current = start var best = values.calulateBest(current) step /=2 while (step > 2*EPSILON) { val left = values.calulateBest(current - step) val right = values.calulateBest(current + step) best = best.coerceAtMost(left).coerceAtMost(right) when(best) { left -> current-=step right -> current+= step } // println("$step: $best ( $current)") step /=2 } println(best) } const val SPEED = 1000 const val EPSILON = 1e-7 fun List.calulateBest(currentFramerate: Double) = sumOf { it.calulateBest(currentFramerate) } fun Double.calulateBest(currentFramerate: Double): Double { val timeNeeded = this/SPEED val frameDuration = 1/currentFramerate val test = ceil(timeNeeded/frameDuration) if(test * frameDuration - timeNeeded <= EPSILON) { return timeNeeded } else { return (test)*frameDuration } }