結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー rutilicusrutilicus
提出日時 2020-09-12 12:04:04
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 14,431 ms
コンパイル使用メモリ 413,272 KB
実行使用メモリ 54,420 KB
最終ジャッジ日時 2023-08-30 05:19:27
合計ジャッジ時間 27,560 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 275 ms
52,580 KB
testcase_01 AC 282 ms
54,420 KB
testcase_02 AC 284 ms
52,972 KB
testcase_03 AC 291 ms
52,620 KB
testcase_04 AC 296 ms
52,644 KB
testcase_05 AC 291 ms
52,752 KB
testcase_06 AC 290 ms
52,676 KB
testcase_07 AC 284 ms
52,616 KB
testcase_08 AC 289 ms
52,864 KB
testcase_09 AC 293 ms
52,780 KB
testcase_10 AC 293 ms
52,900 KB
testcase_11 AC 295 ms
52,780 KB
testcase_12 AC 290 ms
52,756 KB
testcase_13 AC 289 ms
52,976 KB
testcase_14 AC 282 ms
52,764 KB
testcase_15 AC 292 ms
52,600 KB
testcase_16 AC 291 ms
52,676 KB
testcase_17 AC 291 ms
52,652 KB
testcase_18 AC 293 ms
52,720 KB
testcase_19 AC 292 ms
52,980 KB
testcase_20 AC 293 ms
52,492 KB
testcase_21 AC 297 ms
52,704 KB
testcase_22 AC 288 ms
52,608 KB
testcase_23 AC 290 ms
52,808 KB
testcase_24 AC 289 ms
52,648 KB
testcase_25 AC 287 ms
52,720 KB
testcase_26 AC 284 ms
52,684 KB
testcase_27 AC 290 ms
52,616 KB
testcase_28 AC 281 ms
52,724 KB
testcase_29 AC 283 ms
52,624 KB
testcase_30 AC 280 ms
52,508 KB
testcase_31 AC 281 ms
52,480 KB
testcase_32 AC 282 ms
52,948 KB
testcase_33 AC 287 ms
52,668 KB
testcase_34 AC 287 ms
53,060 KB
testcase_35 AC 286 ms
52,984 KB
testcase_36 AC 287 ms
52,740 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:41:13: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
    builder.appendln(ans)
            ^

ソースコード

diff #

import kotlin.math.max

fun main() {
    val builder = StringBuilder()

    // なにもわからん
    val n = readInputLine().toInt()

    val s = readInputLine()
    val t = readInputLine()

    var s1Cnt = 0
    var s2Cnt = 0
    var t1Cnt = 0
    var t2Cnt = 0

    for (c in s) {
        when (c) {
            '1' -> s1Cnt++
            '2' -> s2Cnt++
        }
    }

    for (c in t) {
        when (c) {
            '1' -> t1Cnt++
            '2' -> t2Cnt++
        }
    }

    var ans = if (s2Cnt != 0 && t2Cnt != 0) {
        n * (s2Cnt + t2Cnt) - s2Cnt * t2Cnt
    } else if (t2Cnt != 0) {
        n * t2Cnt + t1Cnt
    } else if (s2Cnt != 0) {
        n * s2Cnt + s1Cnt
    } else {
        max(s1Cnt, t1Cnt)
    }

    builder.appendln(ans)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0