結果

問題 No.216 FAC
コンテスト
ユーザー komkomh
提出日時 2019-06-06 20:59:10
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 697 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,394 ms
コンパイル使用メモリ 475,904 KB
実行使用メモリ 54,208 KB
最終ジャッジ日時 2026-05-14 22:11:33
合計ジャッジ時間 16,041 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 RE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:11:38: warning: 'fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int' is deprecated. Use sumOf instead.
        .map { Pair(it.key, it.value.sumBy { pair -> pair.second }) }
                                     ^^^^^
Main.kt:13:84: warning: unnecessary safe call on a non-null receiver of type 'Pair<Int, Int>'.
    val maxUserScore: Int = userScores.filter { it.first != 0 }.maxBy { it.second }?.let { it.second } ?: run { 0 }
                                                                                   ^^

ソースコード

diff #
raw source code

package yukicoder

fun main() {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt)
    val B = readLine()!!.split(" ").map(String::toInt)

    val userScores: List<Pair<Int, Int>> = (0 until N)
        .map { Pair(B[it], A[it]) }
        .groupBy { it.first }
        .map { Pair(it.key, it.value.sumBy { pair -> pair.second }) }

    val maxUserScore: Int = userScores.filter { it.first != 0 }.maxBy { it.second }?.let { it.second } ?: run { 0 }
    val notSolvedScore = userScores.find { it.first == 0 }?.let { it.second } ?: run { 0 }
    val ans = when (maxUserScore > notSolvedScore) {
        true -> "NO"
        false -> "YES"
    }
    println(ans)
}
0