結果

問題 No.1233 割り切れない気持ち
ユーザー rlangevinrlangevin
提出日時 2023-10-30 12:15:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 3,153 ms
コード長 442 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 111,020 KB
最終ジャッジ日時 2023-10-30 12:15:46
合計ジャッジ時間 6,327 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,584 KB
testcase_01 AC 35 ms
53,584 KB
testcase_02 AC 36 ms
53,584 KB
testcase_03 AC 46 ms
62,252 KB
testcase_04 AC 45 ms
62,164 KB
testcase_05 AC 36 ms
53,584 KB
testcase_06 AC 36 ms
53,584 KB
testcase_07 AC 78 ms
81,328 KB
testcase_08 AC 98 ms
91,256 KB
testcase_09 AC 140 ms
103,232 KB
testcase_10 AC 139 ms
106,488 KB
testcase_11 AC 102 ms
80,904 KB
testcase_12 AC 153 ms
111,020 KB
testcase_13 AC 152 ms
110,696 KB
testcase_14 AC 151 ms
111,020 KB
testcase_15 AC 166 ms
111,020 KB
testcase_16 AC 154 ms
111,020 KB
testcase_17 AC 71 ms
98,652 KB
testcase_18 AC 149 ms
110,960 KB
testcase_19 AC 91 ms
109,528 KB
testcase_20 AC 72 ms
98,652 KB
testcase_21 AC 74 ms
101,936 KB
testcase_22 AC 75 ms
101,936 KB
testcase_23 AC 76 ms
101,936 KB
testcase_24 AC 75 ms
101,936 KB
testcase_25 AC 76 ms
101,936 KB
testcase_26 AC 75 ms
101,936 KB
testcase_27 AC 91 ms
110,172 KB
testcase_28 AC 86 ms
108,904 KB
testcase_29 AC 85 ms
107,892 KB
testcase_30 AC 87 ms
107,876 KB
testcase_31 AC 86 ms
107,860 KB
testcase_32 AC 91 ms
107,872 KB
testcase_33 AC 89 ms
107,836 KB
testcase_34 AC 87 ms
107,844 KB
testcase_35 AC 86 ms
107,868 KB
testcase_36 AC 86 ms
107,848 KB
testcase_37 AC 35 ms
53,584 KB
testcase_38 AC 82 ms
105,488 KB
testcase_39 AC 131 ms
109,656 KB
testcase_40 AC 131 ms
109,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
M = max(A)
D = [0] * (M + 1)
for a in A:
    D[a] += 1

Dc = [0] * (M + 2)
for i in range(M + 1):
    Dc[i + 1] = Dc[i] + D[i]


ans = N * sum(A)
memo = [-1] * (M + 1)
for a in A:
    if memo[a] != -1:
        ans -= memo[a]
        continue
    v = 0
    for i in range(a, M + 1, a):
        v += (Dc[min(i + a, M + 1)] - Dc[i]) * (i // a)
    ans -= a * v
    memo[a] = a * v

print(ans)
0