結果

問題 No.216 FAC
ユーザー komkomhkomkomh
提出日時 2019-06-06 20:59:10
言語 Kotlin
(2.1.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 697 bytes
コンパイル時間 16,808 ms
コンパイル使用メモリ 451,788 KB
実行使用メモリ 57,320 KB
最終ジャッジ日時 2024-11-20 18:44:51
合計ジャッジ時間 23,205 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 RE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:11:38: warning: 'sumBy((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 }
                                                                                   ^
Main.kt:13:104: warning: elvis operator (?:) always returns the left operand of non-nullable type Int
    val maxUserScore: Int = userScores.filter { it.first != 0 }.maxBy { it.second }?.let { it.second } ?: run { 0 }
                                                                                                       ^

ソースコード

diff #

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