結果

問題 No.118 門松列(2)
ユーザー バカらっくバカらっく
提出日時 2019-10-02 03:08:04
言語 Kotlin
(1.9.10)
結果
AC  
実行時間 588 ms / 5,000 ms
コード長 908 bytes
コンパイル時間 18,694 ms
コンパイル使用メモリ 426,640 KB
実行使用メモリ 60,008 KB
最終ジャッジ日時 2023-07-26 19:18:21
合計ジャッジ時間 28,778 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 369 ms
57,768 KB
testcase_01 AC 588 ms
59,728 KB
testcase_02 AC 571 ms
59,556 KB
testcase_03 AC 577 ms
60,008 KB
testcase_04 AC 569 ms
59,736 KB
testcase_05 AC 570 ms
59,648 KB
testcase_06 AC 295 ms
57,140 KB
testcase_07 AC 298 ms
56,992 KB
testcase_08 AC 282 ms
56,964 KB
testcase_09 AC 581 ms
59,716 KB
testcase_10 AC 453 ms
58,600 KB
testcase_11 AC 474 ms
58,456 KB
testcase_12 AC 447 ms
58,432 KB
testcase_13 AC 448 ms
58,676 KB
testcase_14 AC 577 ms
59,980 KB
testcase_15 AC 356 ms
58,236 KB
testcase_16 AC 534 ms
59,860 KB
testcase_17 AC 506 ms
58,416 KB
testcase_18 AC 462 ms
58,372 KB
testcase_19 AC 540 ms
59,740 KB
testcase_20 AC 527 ms
59,604 KB
testcase_21 AC 580 ms
59,656 KB
testcase_22 AC 488 ms
58,300 KB
testcase_23 AC 568 ms
59,704 KB
testcase_24 AC 478 ms
58,424 KB
testcase_25 AC 531 ms
59,616 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