結果

問題 No.1110 好きな歌
コンテスト
ユーザー convexineq
提出日時 2021-04-11 02:19:23
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 1,032 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 468 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 1,017,744 KB
最終ジャッジ日時 2026-03-13 20:44:35
合計ジャッジ時間 9,178 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 RE * 46 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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