結果

問題 No.1110 好きな歌
ユーザー 👑 KazunKazun
提出日時 2020-07-10 21:49:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 282 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 84,772 KB
最終ジャッジ日時 2024-04-19 16:45:54
合計ジャッジ時間 9,773 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,224 KB
testcase_01 AC 33 ms
52,224 KB
testcase_02 AC 33 ms
51,968 KB
testcase_03 AC 33 ms
51,968 KB
testcase_04 AC 34 ms
52,096 KB
testcase_05 AC 33 ms
52,608 KB
testcase_06 AC 34 ms
51,840 KB
testcase_07 AC 34 ms
52,096 KB
testcase_08 AC 35 ms
52,224 KB
testcase_09 AC 34 ms
52,224 KB
testcase_10 AC 33 ms
51,968 KB
testcase_11 AC 34 ms
52,352 KB
testcase_12 AC 34 ms
52,224 KB
testcase_13 AC 35 ms
52,224 KB
testcase_14 AC 44 ms
60,928 KB
testcase_15 AC 39 ms
54,144 KB
testcase_16 AC 45 ms
61,312 KB
testcase_17 AC 52 ms
64,512 KB
testcase_18 AC 36 ms
52,224 KB
testcase_19 AC 52 ms
64,640 KB
testcase_20 AC 50 ms
63,616 KB
testcase_21 AC 45 ms
60,288 KB
testcase_22 AC 48 ms
62,976 KB
testcase_23 AC 38 ms
53,504 KB
testcase_24 AC 185 ms
81,368 KB
testcase_25 AC 211 ms
82,008 KB
testcase_26 AC 153 ms
79,488 KB
testcase_27 AC 204 ms
82,132 KB
testcase_28 AC 141 ms
80,328 KB
testcase_29 AC 246 ms
81,932 KB
testcase_30 AC 127 ms
80,128 KB
testcase_31 AC 120 ms
79,484 KB
testcase_32 AC 254 ms
83,900 KB
testcase_33 AC 134 ms
81,028 KB
testcase_34 AC 177 ms
81,492 KB
testcase_35 AC 200 ms
84,088 KB
testcase_36 AC 86 ms
76,888 KB
testcase_37 AC 130 ms
79,680 KB
testcase_38 AC 236 ms
82,316 KB
testcase_39 AC 191 ms
81,056 KB
testcase_40 AC 169 ms
81,800 KB
testcase_41 AC 89 ms
76,672 KB
testcase_42 AC 210 ms
83,620 KB
testcase_43 AC 240 ms
82,056 KB
testcase_44 AC 221 ms
84,368 KB
testcase_45 AC 270 ms
84,652 KB
testcase_46 AC 250 ms
84,772 KB
testcase_47 AC 282 ms
84,344 KB
testcase_48 AC 257 ms
84,264 KB
testcase_49 AC 193 ms
84,332 KB
testcase_50 AC 259 ms
83,888 KB
testcase_51 AC 234 ms
84,268 KB
testcase_52 AC 260 ms
83,956 KB
testcase_53 AC 277 ms
84,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Binary_Search_Count(A,x,sort=True,equal=False):
    """2分探索によって,x未満の要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"未満"がx"以下"になる
    """
    if sort:
        A.sort()
        
    N=len(A)
    if A[-1]<=x:
        return N
    elif x<A[0] or (not equal and x==A[0]):
        return 0

    L,R=0,N
    while R-L>1:
        C=L+(R-L)//2
        if x<A[C] or (not equal and x==A[C]):
            R=C
        else:
            L=C
    return R
#--------------------------------------------------------------
N,D=map(int,input().split())
A=[]
for _ in range(N):
    A.append(int(input()))

B=sorted(A)
for a in A:
    print(Binary_Search_Count(B,a-D,sort=False,equal=True))
0