結果

問題 No.1233 割り切れない気持ち
ユーザー cmycmy
提出日時 2022-08-18 02:55:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 931 ms / 3,153 ms
コード長 458 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 122,112 KB
最終ジャッジ日時 2024-04-15 13:47:41
合計ジャッジ時間 14,517 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,004 KB
testcase_01 AC 39 ms
52,352 KB
testcase_02 AC 45 ms
59,008 KB
testcase_03 AC 66 ms
70,656 KB
testcase_04 AC 63 ms
69,632 KB
testcase_05 AC 43 ms
57,600 KB
testcase_06 AC 45 ms
58,240 KB
testcase_07 AC 235 ms
86,460 KB
testcase_08 AC 343 ms
95,556 KB
testcase_09 AC 616 ms
114,816 KB
testcase_10 AC 668 ms
107,904 KB
testcase_11 AC 204 ms
85,760 KB
testcase_12 AC 698 ms
110,336 KB
testcase_13 AC 725 ms
110,252 KB
testcase_14 AC 744 ms
110,092 KB
testcase_15 AC 740 ms
109,964 KB
testcase_16 AC 732 ms
109,928 KB
testcase_17 AC 126 ms
122,112 KB
testcase_18 AC 931 ms
114,848 KB
testcase_19 AC 173 ms
113,664 KB
testcase_20 AC 128 ms
122,028 KB
testcase_21 AC 193 ms
111,532 KB
testcase_22 AC 189 ms
110,924 KB
testcase_23 AC 189 ms
111,104 KB
testcase_24 AC 192 ms
111,488 KB
testcase_25 AC 195 ms
111,616 KB
testcase_26 AC 188 ms
111,592 KB
testcase_27 AC 199 ms
112,160 KB
testcase_28 AC 198 ms
111,104 KB
testcase_29 AC 199 ms
111,752 KB
testcase_30 AC 194 ms
111,608 KB
testcase_31 AC 198 ms
111,736 KB
testcase_32 AC 197 ms
111,488 KB
testcase_33 AC 198 ms
111,036 KB
testcase_34 AC 200 ms
111,360 KB
testcase_35 AC 196 ms
111,252 KB
testcase_36 AC 200 ms
111,648 KB
testcase_37 AC 39 ms
52,352 KB
testcase_38 AC 133 ms
121,872 KB
testcase_39 AC 562 ms
109,688 KB
testcase_40 AC 567 ms
109,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

n = int(input())
*a, = map(int, input().split())
a.sort()

s = [0]
for ai in a:
    s.append(s[-1]+ai)

ans = 0
cache = {1: 0}
for i, ai in enumerate(a):
    ans += s[bisect_left(a, ai)]

    if ai not in cache:
        j = i
        cache[ai] = s[-1] - s[j]
        for aj in range(ai, a[-1]+1, ai):
            k = bisect_left(a, aj+ai)
            cache[ai] -= aj * (k-j)
            j = k
    ans += cache[ai]

print(ans)
0