結果
| 問題 |
No.1233 割り切れない気持ち
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-28 18:27:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 153 ms / 3,153 ms |
| コード長 | 529 bytes |
| コンパイル時間 | 443 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 109,312 KB |
| 最終ジャッジ日時 | 2024-12-29 20:21:45 |
| 合計ジャッジ時間 | 6,075 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 39 |
ソースコード
n = int(input())
A = list(map(int, input().split()))
N = max(A) + 10
cnt = [0] * (N + 1)
tot = [0] * (N + 1)
for a in A:
cnt[a] += 1
tot[a] += a
for i in range(N):
cnt[i + 1] += cnt[i]
tot[i + 1] += tot[i]
ans = 0
for i in range(1, N + 1):
c = cnt[i] - cnt[i - 1]
if c == 0:
continue
ans += c * tot[i - 1]
j = i
while j < N:
cc = cnt[min(j + i - 1, N)] - cnt[j]
tt = tot[min(j + i - 1, N)] - tot[j]
ans += c * (tt - cc * j)
j += i
print(ans)