結果

問題 No.1233 割り切れない気持ち
ユーザー anagohirameanagohirame
提出日時 2020-09-18 23:51:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 496 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 109,192 KB
最終ジャッジ日時 2023-09-04 19:49:16
合計ジャッジ時間 7,361 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
77,568 KB
testcase_01 AC 81 ms
77,492 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 116 ms
106,128 KB
testcase_18 WA -
testcase_19 AC 120 ms
108,944 KB
testcase_20 AC 113 ms
105,748 KB
testcase_21 AC 120 ms
107,056 KB
testcase_22 AC 120 ms
107,492 KB
testcase_23 AC 120 ms
107,460 KB
testcase_24 AC 119 ms
107,064 KB
testcase_25 AC 121 ms
107,352 KB
testcase_26 AC 119 ms
107,196 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 122 ms
107,892 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 122 ms
107,772 KB
testcase_34 WA -
testcase_35 AC 123 ms
107,732 KB
testcase_36 AC 123 ms
107,624 KB
testcase_37 AC 81 ms
77,504 KB
testcase_38 AC 113 ms
105,604 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

MAX = 200001
cum = [0 for _ in range(MAX)]
for x in a:
	cum[x] += 1
for i in range(1, MAX):
	cum[i] += cum[i-1]

ans = 0
tot = sum(a)
s = cum[1]
for i in range(2, MAX):
	num = cum[i] - cum[i-1]
	if num == 0:
		continue
	ans += num * s
	tmp = tot - s - i * num
	tmp -= i * (cum[min(MAX-1, 2*i)] - cum[i])
	for j in range(2*i, MAX, i):
		k = min(MAX-1, j+i)
		tmp -= i * (j//i) * (cum[k-1] - cum[j-1])
	ans += num * tmp
	s += i * num
print(ans)
0