結果

問題 No.29 パワーアップ
ユーザー minokasagominokasago
提出日時 2019-11-01 15:21:19
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 310 ms / 5,000 ms
コード長 360 bytes
コンパイル時間 12,767 ms
コンパイル使用メモリ 419,740 KB
実行使用メモリ 54,724 KB
最終ジャッジ日時 2023-10-13 00:49:01
合計ジャッジ時間 21,126 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 301 ms
52,816 KB
testcase_01 AC 299 ms
52,788 KB
testcase_02 AC 296 ms
53,024 KB
testcase_03 AC 295 ms
52,844 KB
testcase_04 AC 301 ms
52,672 KB
testcase_05 AC 308 ms
53,052 KB
testcase_06 AC 300 ms
52,908 KB
testcase_07 AC 303 ms
52,924 KB
testcase_08 AC 299 ms
52,812 KB
testcase_09 AC 295 ms
52,856 KB
testcase_10 AC 305 ms
52,912 KB
testcase_11 AC 310 ms
52,972 KB
testcase_12 AC 301 ms
52,904 KB
testcase_13 AC 302 ms
52,904 KB
testcase_14 AC 301 ms
52,932 KB
testcase_15 AC 302 ms
53,052 KB
testcase_16 AC 301 ms
52,968 KB
testcase_17 AC 299 ms
52,836 KB
testcase_18 AC 297 ms
52,856 KB
testcase_19 AC 304 ms
54,724 KB
testcase_20 AC 301 ms
52,900 KB
testcase_21 AC 296 ms
52,800 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:12:15: warning: variable 'ans' initializer is redundant
    var ans = 0
              ^

ソースコード

diff #

import kotlin.math.*

fun main()
{
    val N = readLine()!!.toInt()
    val cnt = Array<Int>(11, {0})

    repeat(N) {
        readLine()!!.split(" ").map(String::toInt).forEach { cnt[it]++ }
    }

    var ans = 0
    var sum = 0
    var pairs = 0
    cnt.forEach { c ->  sum += c; pairs += c / 2 }
    ans = pairs + (sum - pairs * 2) / 4
    println(ans)
}

0