結果

問題 No.29 パワーアップ
ユーザー minokasagominokasago
提出日時 2019-11-01 15:21:19
言語 Kotlin
(1.6.10)
結果
AC  
実行時間 276 ms / 5,000 ms
コード長 360 bytes
コンパイル時間 11,778 ms
使用メモリ 46,564 KB
最終ジャッジ日時 2023-02-27 15:22:10
合計ジャッジ時間 18,762 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 255 ms
45,936 KB
testcase_01 AC 250 ms
46,032 KB
testcase_02 AC 264 ms
45,908 KB
testcase_03 AC 257 ms
45,904 KB
testcase_04 AC 254 ms
45,916 KB
testcase_05 AC 259 ms
45,896 KB
testcase_06 AC 261 ms
45,844 KB
testcase_07 AC 254 ms
45,892 KB
testcase_08 AC 260 ms
46,128 KB
testcase_09 AC 257 ms
45,824 KB
testcase_10 AC 264 ms
46,072 KB
testcase_11 AC 256 ms
45,908 KB
testcase_12 AC 257 ms
45,916 KB
testcase_13 AC 276 ms
46,564 KB
testcase_14 AC 260 ms
45,776 KB
testcase_15 AC 261 ms
46,056 KB
testcase_16 AC 259 ms
45,912 KB
testcase_17 AC 259 ms
45,852 KB
testcase_18 AC 252 ms
46,044 KB
testcase_19 AC 258 ms
45,964 KB
testcase_20 AC 257 ms
45,936 KB
testcase_21 AC 254 ms
46,060 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