結果

問題 No.647 明太子
ユーザー 💕💖💞
提出日時 2018-02-15 21:59:40
言語 Kotlin
(2.1.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 12,802 ms
コンパイル使用メモリ 442,988 KB
実行使用メモリ 85,788 KB
最終ジャッジ日時 2024-11-20 13:44:01
合計ジャッジ時間 25,792 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 17 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) { 
         ^
Main.kt:22:38: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Pair<Int, Int>
  val max = pairs.maxBy { it.second }!!.second
                                     ^

ソースコード

diff #

fun main(args:Array<String>) { 
  val persons = (1..readLine()!!.toInt()).map { 
    val p = readLine()!!.split(" ").map{ it.toInt() }
    Pair(p[0], p[1])
  }
  val mentais = (1..readLine()!!.toInt()).map { 
    val p = readLine()!!.split(" ").map{ it.toInt() }
    Pair(p[0], p[1])
  }

  // first 値段
  // second からさ
  val pairs = mentais.mapIndexed { i,mentai ->
    val score = persons.map { person ->
      when {
        mentai.first <= person.first && person.second <= mentai.second -> 1
        else -> 0
      }
    }.sum()
    Pair(i+1, score)
  }
  val max = pairs.maxBy { it.second }!!.second

  when { 
    max == 0 -> {}
    else -> {
      pairs.filter { it.second == max }.map { 
        println(it.first)
      }
    }
  }
}
0