結果

問題 No.1233 割り切れない気持ち
ユーザー yudedakoyudedako
提出日時 2022-01-10 17:10:27
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,492 ms / 3,153 ms
コード長 765 bytes
コンパイル時間 11,475 ms
コンパイル使用メモリ 436,780 KB
実行使用メモリ 98,592 KB
最終ジャッジ日時 2024-04-26 20:12:45
合計ジャッジ時間 48,545 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 353 ms
56,008 KB
testcase_01 AC 352 ms
55,856 KB
testcase_02 AC 358 ms
56,260 KB
testcase_03 AC 405 ms
56,292 KB
testcase_04 AC 408 ms
56,244 KB
testcase_05 AC 375 ms
55,852 KB
testcase_06 AC 368 ms
56,364 KB
testcase_07 AC 775 ms
64,960 KB
testcase_08 AC 995 ms
68,552 KB
testcase_09 AC 1,298 ms
77,484 KB
testcase_10 AC 1,374 ms
78,160 KB
testcase_11 AC 760 ms
63,740 KB
testcase_12 AC 1,392 ms
98,492 KB
testcase_13 AC 1,477 ms
98,504 KB
testcase_14 AC 1,372 ms
98,592 KB
testcase_15 AC 1,492 ms
98,556 KB
testcase_16 AC 1,366 ms
98,404 KB
testcase_17 AC 632 ms
73,600 KB
testcase_18 AC 1,011 ms
96,536 KB
testcase_19 AC 721 ms
96,776 KB
testcase_20 AC 644 ms
73,760 KB
testcase_21 AC 872 ms
79,840 KB
testcase_22 AC 864 ms
79,724 KB
testcase_23 AC 873 ms
79,900 KB
testcase_24 AC 904 ms
79,808 KB
testcase_25 AC 899 ms
79,616 KB
testcase_26 AC 886 ms
79,672 KB
testcase_27 AC 951 ms
80,100 KB
testcase_28 AC 901 ms
79,992 KB
testcase_29 AC 925 ms
79,828 KB
testcase_30 AC 926 ms
79,936 KB
testcase_31 AC 892 ms
80,004 KB
testcase_32 AC 907 ms
79,956 KB
testcase_33 AC 970 ms
79,956 KB
testcase_34 AC 880 ms
80,040 KB
testcase_35 AC 883 ms
80,220 KB
testcase_36 AC 901 ms
80,008 KB
testcase_37 AC 346 ms
52,552 KB
testcase_38 AC 671 ms
73,544 KB
testcase_39 AC 928 ms
76,828 KB
testcase_40 AC 947 ms
76,892 KB
権限があれば一括ダウンロードができます

ソースコード

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 .. 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