結果

問題 No.564 背の順
ユーザー 💕💖💞💕💖💞
提出日時 2017-09-09 01:03:34
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 575 bytes
コンパイル時間 12,901 ms
コンパイル使用メモリ 436,080 KB
実行使用メモリ 60,576 KB
最終ジャッジ日時 2024-04-30 15:44:14
合計ジャッジ時間 14,727 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
60,336 KB
testcase_01 AC 282 ms
60,436 KB
testcase_02 AC 292 ms
60,496 KB
testcase_03 WA -
testcase_04 AC 288 ms
60,408 KB
testcase_05 AC 295 ms
60,500 KB
testcase_06 AC 303 ms
60,544 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 297 ms
60,404 KB
testcase_10 AC 291 ms
60,400 KB
testcase_11 AC 292 ms
60,324 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:11: warning: parameter 'args' is never used
fun main( args : Array<String> ) {
          ^
Main.kt:12:16: warning: name shadowed: h
    val (type, h) = x
               ^

ソースコード

diff #

fun main( args : Array<String> ) {
  val (h, n) = readLine()!!.split(" ").map { it.toInt() }
  val ns = (1..n-1).map {
    readLine()!!.toInt()
  }.map { 
    Pair("Other", it)
  }.toMutableList()
  ns.add( Pair("Target", h) )
  ns.sortedBy{ 
    it.second * -1
  }.mapIndexed { i,x ->
    val (type, h) = x
    Triple(type, i+1, h)
  }.filter {
    it.first == "Target"
  }.let { 
    val rank = it.first().second 
    when {
      rank == 1 -> println("1st")
      rank == 2 -> println("2nd")
      rank == 3 -> println("3rd")
      else -> println("${rank}th")
    }
  }
}
0