Advertisement
paranid5

1_VSHE

Apr 17th, 2021
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.65 KB | None | 0 0
  1. import kotlin.system.exitProcess
  2.  
  3. fun main() {
  4.     readLine()
  5.  
  6.     mutableMapOf<Int, Int>().let { map ->
  7.         var maxKey = 0
  8.         val vec = readLine()!!.trim().split(' ').map { it.toInt() }
  9.  
  10.         vec.forEach {
  11.             map[it] = map.getOrPut(it) { 0 } + 1
  12.  
  13.             if (map[it]!! > maxKey)
  14.                 maxKey = map[it]!!
  15.         }
  16.  
  17.         mutableMapOf<Int, Int>().let { map2 ->
  18.             vec.forEach {
  19.                 map2[it] = map2.getOrPut(it) { 0 } + 1
  20.  
  21.                 if (map2[it]!! == maxKey) {
  22.                     println(it)
  23.                     exitProcess(0)
  24.                 }
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement