結果

問題 No.1233 割り切れない気持ち
ユーザー mkawa2mkawa2
提出日時 2021-07-26 22:27:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 967 ms / 3,153 ms
コード長 1,021 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 49,632 KB
最終ジャッジ日時 2023-09-29 19:19:16
合計ジャッジ時間 17,055 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
11,644 KB
testcase_01 AC 53 ms
11,636 KB
testcase_02 AC 168 ms
11,640 KB
testcase_03 AC 304 ms
18,000 KB
testcase_04 AC 257 ms
18,056 KB
testcase_05 AC 193 ms
11,668 KB
testcase_06 AC 209 ms
11,664 KB
testcase_07 AC 537 ms
23,352 KB
testcase_08 AC 582 ms
27,956 KB
testcase_09 AC 722 ms
37,596 KB
testcase_10 AC 744 ms
37,980 KB
testcase_11 AC 489 ms
23,004 KB
testcase_12 AC 806 ms
39,192 KB
testcase_13 AC 752 ms
39,152 KB
testcase_14 AC 801 ms
39,144 KB
testcase_15 AC 841 ms
39,120 KB
testcase_16 AC 828 ms
39,112 KB
testcase_17 AC 173 ms
19,924 KB
testcase_18 AC 967 ms
49,632 KB
testcase_19 AC 185 ms
31,740 KB
testcase_20 AC 203 ms
19,928 KB
testcase_21 AC 210 ms
31,152 KB
testcase_22 AC 200 ms
31,148 KB
testcase_23 AC 203 ms
31,200 KB
testcase_24 AC 202 ms
31,184 KB
testcase_25 AC 195 ms
31,192 KB
testcase_26 AC 193 ms
32,032 KB
testcase_27 AC 204 ms
31,092 KB
testcase_28 AC 207 ms
31,060 KB
testcase_29 AC 198 ms
31,068 KB
testcase_30 AC 206 ms
31,112 KB
testcase_31 AC 205 ms
31,084 KB
testcase_32 AC 199 ms
31,092 KB
testcase_33 AC 200 ms
31,128 KB
testcase_34 AC 196 ms
31,136 KB
testcase_35 AC 191 ms
31,004 KB
testcase_36 AC 189 ms
31,056 KB
testcase_37 AC 54 ms
11,632 KB
testcase_38 AC 199 ms
19,832 KB
testcase_39 AC 606 ms
35,356 KB
testcase_40 AC 585 ms
35,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

from functools import lru_cache

mx = 200005
n = II()
aa = LI()

cnt = [0]*mx
for a in aa: cnt[a] += 1
cs = [0]
for c in cnt: cs.append(cs[-1]+c)

@lru_cache(None)
def f(a):
    res = 0
    for i in range(1, mx):
        l, r = i*a, (i+1)*a
        if r >= mx: r = mx-1
        res += (cs[r]-cs[l])*i
        if r == mx-1: break
    return res

s = sum(aa)
ans = s*n
for a in aa: ans -= a*f(a)
print(ans)
0