結果

問題 No.118 門松列(2)
コンテスト
ユーザー バカらっく
提出日時 2019-10-02 03:01:50
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
WA  
実行時間 -
コード長 779 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,826 ms
コンパイル使用メモリ 481,900 KB
実行使用メモリ 70,316 KB
最終ジャッジ日時 2026-04-19 07:29:57
合計ジャッジ時間 22,211 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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