結果

問題 No.2046 Ans Mod? Mod Ans!
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-08-19 22:47:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 957 ms / 4,000 ms
コード長 421 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 121,992 KB
最終ジャッジ日時 2024-05-09 17:28:17
合計ジャッジ時間 5,958 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,696 KB
testcase_01 AC 38 ms
52,268 KB
testcase_02 AC 37 ms
53,288 KB
testcase_03 AC 57 ms
70,952 KB
testcase_04 AC 56 ms
67,460 KB
testcase_05 AC 61 ms
70,484 KB
testcase_06 AC 56 ms
66,924 KB
testcase_07 AC 56 ms
68,644 KB
testcase_08 AC 77 ms
76,584 KB
testcase_09 AC 77 ms
76,164 KB
testcase_10 AC 79 ms
76,156 KB
testcase_11 AC 85 ms
76,208 KB
testcase_12 AC 83 ms
75,996 KB
testcase_13 AC 348 ms
93,264 KB
testcase_14 AC 288 ms
87,992 KB
testcase_15 AC 512 ms
101,784 KB
testcase_16 AC 551 ms
101,948 KB
testcase_17 AC 432 ms
97,872 KB
testcase_18 AC 454 ms
98,732 KB
testcase_19 AC 404 ms
98,540 KB
testcase_20 AC 957 ms
121,992 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