結果

問題 No.216 FAC
ユーザー komkomhkomkomh
提出日時 2019-06-06 20:59:10
言語 Kotlin
(1.9.23)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 697 bytes
コンパイル時間 13,602 ms
コンパイル使用メモリ 449,252 KB
実行使用メモリ 57,324 KB
最終ジャッジ日時 2024-04-30 20:52:51
合計ジャッジ時間 23,820 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 325 ms
57,024 KB
testcase_01 AC 331 ms
56,924 KB
testcase_02 AC 327 ms
57,060 KB
testcase_03 AC 344 ms
57,052 KB
testcase_04 AC 331 ms
57,032 KB
testcase_05 AC 332 ms
57,020 KB
testcase_06 AC 330 ms
57,020 KB
testcase_07 RE -
testcase_08 AC 327 ms
56,900 KB
testcase_09 AC 326 ms
57,064 KB
testcase_10 AC 328 ms
57,016 KB
testcase_11 AC 322 ms
57,228 KB
testcase_12 AC 325 ms
56,980 KB
testcase_13 AC 323 ms
56,980 KB
testcase_14 AC 329 ms
56,976 KB
testcase_15 AC 326 ms
56,976 KB
testcase_16 AC 334 ms
57,100 KB
testcase_17 AC 334 ms
57,324 KB
testcase_18 AC 333 ms
57,292 KB
testcase_19 AC 337 ms
57,300 KB
testcase_20 AC 334 ms
57,068 KB
testcase_21 AC 335 ms
57,072 KB
testcase_22 AC 337 ms
57,280 KB
testcase_23 AC 339 ms
57,156 KB
testcase_24 AC 335 ms
57,256 KB
testcase_25 AC 339 ms
57,188 KB
testcase_26 AC 330 ms
57,100 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