結果

問題 No.1233 割り切れない気持ち
ユーザー AEnAEn
提出日時 2022-12-17 19:27:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 216 ms / 3,153 ms
コード長 544 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 112,736 KB
最終ジャッジ日時 2024-04-28 12:51:55
合計ジャッジ時間 6,598 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
62,584 KB
testcase_01 AC 50 ms
63,816 KB
testcase_02 AC 62 ms
64,484 KB
testcase_03 AC 77 ms
67,664 KB
testcase_04 AC 76 ms
65,844 KB
testcase_05 AC 62 ms
62,772 KB
testcase_06 AC 65 ms
63,612 KB
testcase_07 AC 136 ms
88,596 KB
testcase_08 AC 144 ms
93,028 KB
testcase_09 AC 196 ms
103,272 KB
testcase_10 AC 200 ms
105,716 KB
testcase_11 AC 129 ms
87,480 KB
testcase_12 AC 201 ms
109,256 KB
testcase_13 AC 216 ms
109,200 KB
testcase_14 AC 209 ms
109,264 KB
testcase_15 AC 197 ms
109,456 KB
testcase_16 AC 205 ms
109,640 KB
testcase_17 AC 92 ms
103,624 KB
testcase_18 AC 193 ms
112,736 KB
testcase_19 AC 105 ms
109,784 KB
testcase_20 AC 84 ms
101,268 KB
testcase_21 AC 97 ms
105,664 KB
testcase_22 AC 98 ms
105,324 KB
testcase_23 AC 98 ms
105,572 KB
testcase_24 AC 98 ms
105,992 KB
testcase_25 AC 101 ms
106,136 KB
testcase_26 AC 99 ms
106,208 KB
testcase_27 AC 109 ms
108,772 KB
testcase_28 AC 110 ms
108,816 KB
testcase_29 AC 100 ms
106,840 KB
testcase_30 AC 99 ms
107,392 KB
testcase_31 AC 100 ms
106,768 KB
testcase_32 AC 101 ms
106,592 KB
testcase_33 AC 103 ms
107,140 KB
testcase_34 AC 102 ms
106,664 KB
testcase_35 AC 101 ms
107,416 KB
testcase_36 AC 101 ms
107,204 KB
testcase_37 AC 49 ms
63,404 KB
testcase_38 AC 86 ms
101,576 KB
testcase_39 AC 147 ms
108,508 KB
testcase_40 AC 148 ms
108,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

cnt = [0]*(2*10**5+5)
sm = [0]*(2*10**5+5)
for i in range(N):
    cnt[A[i]] += 1
    sm[A[i]] += A[i]
for i in range(2*10**5+4):
    cnt[i+1] += cnt[i]
    sm[i+1] += sm[i]

res = 0
mem = {}
for i in range(N):
    if A[i]==1:continue
    m = 0
    res += sm[-1]
    if A[i] in mem:
        res -= A[i]*mem[A[i]]
    else:
        for j in range(A[i],2*10**5+5,A[i]):
            m += (j//A[i])*(cnt[min(j+A[i],2*10**5+4)-1]-cnt[j-1])
        mem[A[i]] = m
        res -= A[i]*m
print(res)

0