結果

問題 No.118 門松列(2)
ユーザー バカらっくバカらっく
提出日時 2019-10-02 03:08:04
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 659 ms / 5,000 ms
コード長 908 bytes
コンパイル時間 14,332 ms
コンパイル使用メモリ 442,332 KB
実行使用メモリ 71,664 KB
最終ジャッジ日時 2024-04-14 08:45:17
合計ジャッジ時間 29,579 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 435 ms
61,060 KB
testcase_01 AC 655 ms
71,560 KB
testcase_02 AC 650 ms
71,664 KB
testcase_03 AC 653 ms
71,556 KB
testcase_04 AC 658 ms
71,504 KB
testcase_05 AC 659 ms
71,616 KB
testcase_06 AC 334 ms
60,452 KB
testcase_07 AC 333 ms
60,548 KB
testcase_08 AC 336 ms
60,464 KB
testcase_09 AC 647 ms
71,476 KB
testcase_10 AC 514 ms
63,436 KB
testcase_11 AC 533 ms
63,516 KB
testcase_12 AC 509 ms
63,768 KB
testcase_13 AC 493 ms
63,652 KB
testcase_14 AC 656 ms
69,396 KB
testcase_15 AC 400 ms
61,100 KB
testcase_16 AC 606 ms
67,312 KB
testcase_17 AC 498 ms
63,520 KB
testcase_18 AC 523 ms
63,476 KB
testcase_19 AC 606 ms
67,392 KB
testcase_20 AC 602 ms
67,336 KB
testcase_21 AC 620 ms
69,424 KB
testcase_22 AC 512 ms
63,480 KB
testcase_23 AC 629 ms
69,420 KB
testcase_24 AC 526 ms
63,468 KB
testcase_25 AC 607 ms
67,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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()
    val mod = 1000000000 + 7
    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()
            var ptn = items[keys[i]]!!.toLong() * items[keys[j]]!!.toLong()
            ptn = ptn % mod
            ptn *= remain
            ptn = ptn % mod
            ans += ptn
            ans = ans % mod
        }
    }
    println(ans)

}

0