結果

問題 No.1233 割り切れない気持ち
ユーザー tktk_snsntktk_snsn
提出日時 2022-06-06 22:04:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 81,528 KB
実行使用メモリ 110,900 KB
最終ジャッジ日時 2023-10-21 03:42:07
合計ジャッジ時間 21,108 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,372 KB
testcase_01 AC 39 ms
53,368 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 82 ms
101,500 KB
testcase_18 AC 1,573 ms
109,052 KB
testcase_19 WA -
testcase_20 AC 83 ms
101,252 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

N = int(input())
A = list(map(int, input().split()))
A.sort()
U = A[-1]
B = [0] * (N + 1)
for i, a in enumerate(A, 1):
    B[i] = a + B[i-1]

ans = 0
s = A[0]
for i in range(1, N):
    if A[i] != A[i-1]:
        ans += s
    s += A[i]


for a in A[::-1]:
    if a == 1:
        break
    x = a
    while x < U:
        y = x + a
        l = bisect.bisect_right(A, x)
        r = bisect.bisect_left(A, y)
        ans += B[r] - B[l]
        ans -= x * (r - l)
        x = y

print(ans)
0