結果

問題 No.216 FAC
ユーザー komkomhkomkomh
提出日時 2019-06-06 20:59:10
言語 Kotlin
(1.9.23)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 697 bytes
コンパイル時間 14,194 ms
コンパイル使用メモリ 424,268 KB
実行使用メモリ 53,236 KB
最終ジャッジ日時 2023-08-13 02:24:56
合計ジャッジ時間 23,494 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 290 ms
52,932 KB
testcase_01 AC 296 ms
53,192 KB
testcase_02 AC 295 ms
52,872 KB
testcase_03 AC 302 ms
53,236 KB
testcase_04 AC 300 ms
52,908 KB
testcase_05 AC 292 ms
52,904 KB
testcase_06 AC 293 ms
52,864 KB
testcase_07 RE -
testcase_08 AC 292 ms
52,996 KB
testcase_09 AC 295 ms
52,780 KB
testcase_10 AC 297 ms
52,908 KB
testcase_11 AC 290 ms
52,892 KB
testcase_12 AC 295 ms
53,228 KB
testcase_13 AC 294 ms
52,784 KB
testcase_14 AC 289 ms
52,896 KB
testcase_15 AC 291 ms
52,912 KB
testcase_16 AC 297 ms
52,840 KB
testcase_17 AC 298 ms
53,084 KB
testcase_18 AC 296 ms
53,068 KB
testcase_19 AC 322 ms
53,116 KB
testcase_20 AC 294 ms
52,956 KB
testcase_21 AC 296 ms
52,896 KB
testcase_22 AC 301 ms
53,032 KB
testcase_23 AC 300 ms
53,016 KB
testcase_24 AC 299 ms
52,908 KB
testcase_25 AC 302 ms
52,840 KB
testcase_26 AC 291 ms
52,904 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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