結果

問題 No.1233 割り切れない気持ち
ユーザー neterukunneterukun
提出日時 2020-09-18 23:10:56
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 185 ms / 3,153 ms
コード長 730 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 110,640 KB
最終ジャッジ日時 2023-09-04 21:53:55
合計ジャッジ時間 9,384 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
80,164 KB
testcase_01 AC 140 ms
80,076 KB
testcase_02 AC 138 ms
80,036 KB
testcase_03 AC 141 ms
80,180 KB
testcase_04 AC 142 ms
80,084 KB
testcase_05 AC 140 ms
80,016 KB
testcase_06 AC 137 ms
79,824 KB
testcase_07 AC 150 ms
86,460 KB
testcase_08 AC 156 ms
91,760 KB
testcase_09 AC 173 ms
103,732 KB
testcase_10 AC 177 ms
106,496 KB
testcase_11 AC 149 ms
85,420 KB
testcase_12 AC 179 ms
110,432 KB
testcase_13 AC 181 ms
110,544 KB
testcase_14 AC 185 ms
110,476 KB
testcase_15 AC 183 ms
110,272 KB
testcase_16 AC 180 ms
110,384 KB
testcase_17 AC 176 ms
108,180 KB
testcase_18 AC 177 ms
110,432 KB
testcase_19 AC 176 ms
110,640 KB
testcase_20 AC 172 ms
107,840 KB
testcase_21 AC 180 ms
109,116 KB
testcase_22 AC 182 ms
108,844 KB
testcase_23 AC 178 ms
109,116 KB
testcase_24 AC 177 ms
108,904 KB
testcase_25 AC 185 ms
109,028 KB
testcase_26 AC 179 ms
109,152 KB
testcase_27 AC 184 ms
109,816 KB
testcase_28 AC 184 ms
109,752 KB
testcase_29 AC 180 ms
109,592 KB
testcase_30 AC 182 ms
109,472 KB
testcase_31 AC 180 ms
109,624 KB
testcase_32 AC 181 ms
109,704 KB
testcase_33 AC 178 ms
109,704 KB
testcase_34 AC 179 ms
109,588 KB
testcase_35 AC 179 ms
109,740 KB
testcase_36 AC 180 ms
109,708 KB
testcase_37 AC 142 ms
80,084 KB
testcase_38 AC 169 ms
107,804 KB
testcase_39 AC 174 ms
109,188 KB
testcase_40 AC 172 ms
109,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))


length = 2 * 10 ** 5 + 10
imos = [0] * length
vals = [0] * length
for i in range(n):
    vals[a[i]] += 1

for diff in range(1, length):
    cnt = vals[diff]
    for i in range(0, length, diff):
        if i + 1 < length:
            imos[i + 1] += 1 * cnt
        if i + diff < length:
            imos[i + diff] -= 1 * cnt


for i in range(length - 1):
    imos[i + 1] += imos[i]

for diff in range(1, length):
    cnt = vals[diff]
    for i in range(0, length, diff):
        if i + diff < length:
            imos[i + diff] -= (diff - 1) * cnt

for i in range(length - 1):
    imos[i + 1] += imos[i]

ans = 0
for i in range(length):
    ans += imos[i] * vals[i]
print(ans)
0