結果

問題 No.1233 割り切れない気持ち
ユーザー yudedakoyudedako
提出日時 2022-01-10 17:07:38
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 14,854 ms
コンパイル使用メモリ 444,140 KB
実行使用メモリ 101,004 KB
最終ジャッジ日時 2024-04-26 20:11:39
合計ジャッジ時間 49,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 378 ms
56,144 KB
testcase_01 AC 349 ms
55,888 KB
testcase_02 AC 375 ms
56,092 KB
testcase_03 AC 396 ms
55,964 KB
testcase_04 AC 450 ms
56,380 KB
testcase_05 AC 403 ms
56,148 KB
testcase_06 AC 388 ms
56,084 KB
testcase_07 AC 786 ms
65,052 KB
testcase_08 AC 998 ms
68,612 KB
testcase_09 AC 1,338 ms
77,628 KB
testcase_10 AC 1,373 ms
78,324 KB
testcase_11 AC 773 ms
63,668 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 642 ms
73,688 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 646 ms
73,744 KB
testcase_21 AC 879 ms
80,040 KB
testcase_22 AC 873 ms
79,564 KB
testcase_23 AC 901 ms
79,864 KB
testcase_24 AC 845 ms
79,792 KB
testcase_25 AC 887 ms
79,864 KB
testcase_26 AC 846 ms
79,892 KB
testcase_27 AC 877 ms
80,228 KB
testcase_28 AC 912 ms
80,124 KB
testcase_29 AC 892 ms
79,920 KB
testcase_30 AC 901 ms
80,052 KB
testcase_31 AC 919 ms
80,048 KB
testcase_32 AC 861 ms
80,076 KB
testcase_33 AC 921 ms
80,136 KB
testcase_34 AC 883 ms
80,072 KB
testcase_35 AC 884 ms
80,032 KB
testcase_36 AC 924 ms
80,144 KB
testcase_37 AC 329 ms
52,704 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

fun List<Int>.lowerBound(target: Int): Int {
    var min = 0
    var max = size
    while (min < max) {
        val mid = (min + max) / 2
        if (this[mid] < target) {
            min = mid + 1
        }else {
            max = mid
        }
    }
    return max
}
const val MAX_VALUE = 200000
fun main() {
    val n = readLine()!!.trim().toInt()
    val num = readLine()!!.trim().split(' ').map(String::toInt).sorted()
    val count = IntArray(MAX_VALUE + 1)
    for (a in num) {
        ++count[a]
    }
    var result = num.fold(0L){acc, v -> acc + v} * n
    for (i in 1 until MAX_VALUE) {
        val m = i.toLong() * count[i]
        for (j in 1 .. MAX_VALUE / i) {
            result -= m * (n - num.lowerBound(i * j))
        }
    }
    println(result)
}
0