結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
74,344 KB
testcase_01 AC 72 ms
74,328 KB
testcase_02 AC 80 ms
78,880 KB
testcase_03 AC 89 ms
79,824 KB
testcase_04 AC 89 ms
79,392 KB
testcase_05 AC 79 ms
78,772 KB
testcase_06 AC 79 ms
78,772 KB
testcase_07 AC 264 ms
86,388 KB
testcase_08 AC 394 ms
91,912 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 231 ms
86,172 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 232 ms
108,068 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 144 ms
108,224 KB
testcase_21 AC 267 ms
109,240 KB
testcase_22 AC 270 ms
109,344 KB
testcase_23 AC 270 ms
109,356 KB
testcase_24 AC 262 ms
109,180 KB
testcase_25 AC 269 ms
109,416 KB
testcase_26 AC 275 ms
109,000 KB
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 #

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 = 4*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(200000):
    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