結果

問題 No.1233 割り切れない気持ち
ユーザー shotoyooshotoyoo
提出日時 2020-09-19 02:18:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 272 ms / 3,153 ms
コード長 736 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 151,956 KB
最終ジャッジ日時 2023-09-05 02:07:39
合計ジャッジ時間 9,842 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,824 KB
testcase_01 AC 89 ms
71,892 KB
testcase_02 AC 89 ms
71,680 KB
testcase_03 AC 100 ms
77,512 KB
testcase_04 AC 98 ms
77,112 KB
testcase_05 AC 90 ms
71,884 KB
testcase_06 AC 89 ms
71,760 KB
testcase_07 AC 159 ms
89,084 KB
testcase_08 AC 188 ms
98,252 KB
testcase_09 AC 233 ms
118,616 KB
testcase_10 AC 245 ms
118,968 KB
testcase_11 AC 149 ms
87,344 KB
testcase_12 AC 264 ms
123,788 KB
testcase_13 AC 264 ms
123,804 KB
testcase_14 AC 264 ms
122,328 KB
testcase_15 AC 267 ms
123,796 KB
testcase_16 AC 272 ms
123,768 KB
testcase_17 AC 137 ms
106,012 KB
testcase_18 AC 254 ms
151,956 KB
testcase_19 AC 148 ms
107,528 KB
testcase_20 AC 134 ms
105,912 KB
testcase_21 AC 160 ms
108,128 KB
testcase_22 AC 160 ms
107,812 KB
testcase_23 AC 164 ms
107,872 KB
testcase_24 AC 158 ms
108,168 KB
testcase_25 AC 159 ms
108,140 KB
testcase_26 AC 166 ms
108,268 KB
testcase_27 AC 181 ms
108,740 KB
testcase_28 AC 183 ms
108,220 KB
testcase_29 AC 180 ms
108,464 KB
testcase_30 AC 177 ms
108,180 KB
testcase_31 AC 176 ms
108,432 KB
testcase_32 AC 175 ms
108,184 KB
testcase_33 AC 178 ms
108,204 KB
testcase_34 AC 183 ms
108,136 KB
testcase_35 AC 179 ms
108,288 KB
testcase_36 AC 175 ms
108,496 KB
testcase_37 AC 87 ms
71,684 KB
testcase_38 AC 147 ms
105,972 KB
testcase_39 AC 216 ms
115,820 KB
testcase_40 AC 208 ms
115,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
a.sort()
from collections import Counter
c = Counter(a)
ks = list(set(a))
ks.sort()
m = max(a)
l = [0]*(m+1)
ans = 0
prv = 0
count = 0
for k in ks:
    for i in range(prv,k+1):
        l[i] += count
    for i in range(2*k,m+1,k):
        l[i] += -k*c[k]
#     print(l)
    count += c[k]
    prv = k+1
for i in range(1,m+1):
    l[i] = l[i-1] + l[i]
v0 = 0
v1 = 0
for i,v in enumerate(l):
    if i in c:
        v0 += c[i]*v
val = 0
for i in range(m,0,-1):
    if i in c:
        v1 += i*c[i]*val
        val += c[i]
ans = v0 + v1
print(ans)
0