結果

問題 No.1470 Mex Sum
ユーザー face4
提出日時 2021-04-10 14:11:32
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 563 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 11,653 ms
コンパイル使用メモリ 430,072 KB
実行使用メモリ 77,092 KB
最終ジャッジ日時 2024-06-26 03:41:01
合計ジャッジ時間 40,577 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:2:9: warning: variable 'n' is never used
    val n = readLine()!!.toInt()
        ^

ソースコード

diff #

fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    var one = 0
    var two = 0
    var others = 0
    println(a.map{
        when(it){
            1L -> 2*one++ + 3*two + 2*others
            2L -> 3*one + 1*two++ + 1*others
            else -> 2*one + 1*two + 1*others++
        }.toLong()
    }.sum())
}
0