結果

問題 No.2046 Ans Mod? Mod Ans!
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-08-19 22:47:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 977 ms / 4,000 ms
コード長 421 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 108,964 KB
最終ジャッジ日時 2023-08-22 11:46:35
合計ジャッジ時間 6,857 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,260 KB
testcase_01 AC 71 ms
70,944 KB
testcase_02 AC 73 ms
71,196 KB
testcase_03 AC 89 ms
76,300 KB
testcase_04 AC 87 ms
76,000 KB
testcase_05 AC 90 ms
76,092 KB
testcase_06 AC 88 ms
75,932 KB
testcase_07 AC 89 ms
75,992 KB
testcase_08 AC 108 ms
77,420 KB
testcase_09 AC 105 ms
77,036 KB
testcase_10 AC 108 ms
77,524 KB
testcase_11 AC 112 ms
77,392 KB
testcase_12 AC 112 ms
77,416 KB
testcase_13 AC 394 ms
94,448 KB
testcase_14 AC 320 ms
89,016 KB
testcase_15 AC 552 ms
103,508 KB
testcase_16 AC 592 ms
103,132 KB
testcase_17 AC 475 ms
99,080 KB
testcase_18 AC 491 ms
99,780 KB
testcase_19 AC 440 ms
99,936 KB
testcase_20 AC 977 ms
108,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
n = int(input())
A = list(map(int,input().split()))
A.sort()
cum = [0]
for a in A:
    cum.append(cum[-1]+a)
ans = 0

for i in range(n-1)[::-1]:
    l = A[i+1]
    a = A[i]
    dl = l//a
    lind = i+1
    while lind < n:
        dl += 1
        rind = bisect_left(A,dl*a)
        ans += (rind-lind)*a
        ans -= (cum[rind]-cum[lind])-(rind-lind)*a*(dl-1)
        lind = rind
print(ans)
0