結果

問題 No.1233 割り切れない気持ち
ユーザー ygd.ygd.
提出日時 2020-09-18 22:49:05
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 823 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 109,316 KB
最終ジャッジ日時 2023-09-04 19:24:21
合計ジャッジ時間 14,033 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
72,824 KB
testcase_01 AC 74 ms
72,804 KB
testcase_02 AC 81 ms
77,324 KB
testcase_03 AC 88 ms
77,964 KB
testcase_04 AC 88 ms
78,144 KB
testcase_05 AC 76 ms
77,280 KB
testcase_06 AC 79 ms
77,244 KB
testcase_07 AC 262 ms
85,092 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 228 ms
84,732 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 230 ms
106,604 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 138 ms
106,820 KB
testcase_21 AC 256 ms
107,668 KB
testcase_22 AC 266 ms
107,480 KB
testcase_23 AC 269 ms
107,804 KB
testcase_24 AC 268 ms
107,576 KB
testcase_25 AC 266 ms
107,696 KB
testcase_26 AC 260 ms
107,740 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 72 ms
72,832 KB
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
 
    def to_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= (i & -i)
        return s
 
    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += (i & -i)
 
    def get(self, i, j):
        return self.to_sum(j)-self.to_sum(i-1)


N = int(input())
MAX = 2*pow(10,5)+10
Tree = BIT(MAX)
A = list(map(int,input().split()))
for i in range(N):
  Tree.add(A[i],1)
S = sum(A)
MAX = max(A)
A.sort()
ans = 0
for x in A:
  if x == 1:
    continue
  wari = 0; now = x; fac = 1
  for i in range(100000):
    wari += Tree.get(now,now+x-1)*fac
    now += x
    fac += 1
    if now > MAX + x:
      break
  #print(wari,S-wari*x)
  ans += S - wari*x
print(ans)

0