結果

問題 No.1233 割り切れない気持ち
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-09-18 22:17:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 120,900 KB
最終ジャッジ日時 2023-09-04 19:14:51
合計ジャッジ時間 8,525 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
91,548 KB
testcase_01 AC 114 ms
91,380 KB
testcase_02 AC 121 ms
91,436 KB
testcase_03 AC 115 ms
91,376 KB
testcase_04 AC 118 ms
91,284 KB
testcase_05 AC 117 ms
91,512 KB
testcase_06 AC 116 ms
91,136 KB
testcase_07 AC 132 ms
97,736 KB
testcase_08 AC 139 ms
103,156 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 127 ms
96,956 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 155 ms
119,224 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 149 ms
119,320 KB
testcase_21 AC 151 ms
119,760 KB
testcase_22 AC 151 ms
119,836 KB
testcase_23 AC 151 ms
119,920 KB
testcase_24 AC 152 ms
119,916 KB
testcase_25 AC 151 ms
119,880 KB
testcase_26 AC 153 ms
119,904 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 115 ms
91,268 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

自分より大きい奴に関しては、そのまま入る
同じ数字を同時に処理することでlog計算量にする

全ての2対 = sum(A) * (N-1)からどこまで減るかを計算する
同じ数字同士は削っておく
数字iがk個あるとする
x*i <= < (x+1)*i に数字がy個あった場合、x*i*k*y減る
これは累積和で行ける

"""

from sys import stdin

N = int(stdin.readline())
A = list(map(int,stdin.readline().split()))

ans = 0
B = [0] * (2*10**5+1)
for i in A:
    ans += i * N
    B[i] += 1

BS = []
for i in range(len(B)):
    if i == 0:
        BS.append(B[i])
    else:
        BS.append(BS[-1] + B[i])

for i in range(1,len(BS)):

    for r in range(2*i-1,len(BS),i):

        l = r - i
        ans -= (l+1) * (BS[r]-BS[l]) * B[i]

print (ans)
0