結果

問題 No.118 門松列(2)
ユーザー バカらっくバカらっく
提出日時 2019-10-02 03:01:50
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 14,802 ms
コンパイル使用メモリ 448,516 KB
実行使用メモリ 73,052 KB
最終ジャッジ日時 2024-04-14 08:44:47
合計ジャッジ時間 30,509 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 337 ms
60,448 KB
testcase_07 AC 332 ms
60,636 KB
testcase_08 AC 336 ms
60,508 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 393 ms
61,220 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
         ^
Main.kt:2:9: warning: variable 'itemCount' is never used
    val itemCount = readLine()!!.toInt()
        ^

ソースコード

diff #

fun main(arr:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val items = readLine()!!.split(" ").map { it.toInt() }.let { a-> a.toSet().sorted().map { b-> b to a.count { it == b } } }.toMap()
    val keys = items.keys.toList()
    val count = items.keys.map { 0 }.toTypedArray()

    for(i in keys.indices) {
        if(i == 0) {
            count[0] = items[keys[0]]!!
        } else {
            count[i] = count[i-1] + items[keys[i]]!!
        }
    }

    var ans = 0L
    for(i in (0..keys.lastIndex - 2)) {
        for(j in (i+1..keys.lastIndex - 1)) {
            val remain = (count.last() - count[j]).toLong()
            val ptn = items[keys[i]]!!.toLong() * items[keys[j]]!!.toLong() * remain
            ans += ptn
        }
    }
    println(ans)

}

0