結果

問題 No.1110 好きな歌
ユーザー convexineqconvexineq
提出日時 2021-04-11 02:19:23
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,032 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 842,984 KB
最終ジャッジ日時 2023-09-09 05:38:09
合計ジャッジ時間 7,244 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,460 KB
testcase_01 AC 76 ms
71,292 KB
testcase_02 AC 74 ms
71,312 KB
testcase_03 AC 74 ms
71,288 KB
testcase_04 RE -
testcase_05 AC 74 ms
71,448 KB
testcase_06 RE -
testcase_07 MLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
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 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

class BIT: #0-indexed
    __slots__ = ["size", "tree","depth","n0"]
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
        self.depth = n.bit_length()
        self.n0 = 1<<self.depth

    def get_sum(self, i): #a_0 + ... + a_{i} #閉区間
        s = 0; i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def range_sum(self,l,r): #a_l + ... + a_r 閉区間
        return self.get_sum(r) - self.get_sum(l-1) 

    def range_sum_larger(self,l): #a_l + ... (端まで)
        return self.get_sum(self.size-1) - (self.get_sum(l-1) if l else 0)
    
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

n,d = map(int,input().split())
a = [int(input()) for _ in range(n)]
#M = 2*10**5+2
M = max(a)+1
bit = BIT(M)
for ai in a:
    bit.add(ai,1)
for ai in a:
    ai -= d
    if ai < 0:
        print(0)
    elif ai >= M:
        print(n-1)
    else:
        print(bit.get_sum(ai))
0