fork download
  1. object Main extends App {
  2. def sortedInput() = {
  3. Iterator.continually(readLine)
  4. .takeWhile(_.ne(null))
  5. .map(BigDecimal.apply)
  6. .toVector.sorted
  7. }
  8.  
  9. val result = sortedInput() match {
  10. case ints if ints.length % 2 == 0
  11. val index = ints.length / 2
  12. ints.slice(index - 1, index + 1).sum / 2
  13.  
  14. case ints ⇒
  15. ints(ints.length / 2)
  16. }
  17.  
  18. println(f"$result%.1f")
  19. }
Success #stdin #stdout 0.4s 322432KB
stdin
3657657868678678675685685
6867867867867887078567556
4587678678678678674674569
5347533552453465454364576
stdout
4967606115566072064519572.5