結果
問題 | No.2046 Ans Mod? Mod Ans! |
ユーザー |
👑 |
提出日時 | 2022-08-19 21:58:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 173 ms / 4,000 ms |
コード長 | 506 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 82,084 KB |
実行使用メモリ | 109,824 KB |
最終ジャッジ日時 | 2024-12-16 08:16:54 |
合計ジャッジ時間 | 2,745 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
n = int(input()) A = list(map(int, input().split())) ma = max(A) + 1 cnt = [0] * ma for a in A: cnt[a] += 1 A.sort() for i in range(ma - 1): cnt[i + 1] += cnt[i] plus = 0 minus = 0 tot = sum(A) for i, a in enumerate(A): plus += a * (n - i - 1) minus += tot tot -= a for j in range(a, ma, a): if j + a < ma: c = cnt[j + a - 1] - cnt[j - 1] minus -= c * j else: c = n - cnt[j - 1] minus -= c * j print(plus - minus)