結果

問題 No.1110 好きな歌
コンテスト
ユーザー tyawanmusi
提出日時 2020-07-10 21:33:10
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 784 ms / 5,000 ms
+ 341µs
コード長 447 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 55,600 KB
最終ジャッジ日時 2026-09-13 20:41:17
合計ジャッジ時間 21,378 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_left,bisect_right
def position_zip(a,flag):
  j=0
  d={}
  for i in sorted(a):
    if i in d:continue
    d[i]=j
    j+=1
  if flag==1:return d
  return [d[i] for i in a]
n,d=map(int,input().split())
a=[int(input())for _ in range(n)]+[-10**10]
b=sorted(list(set(a)))
da=position_zip(a,1)
p=[0]*len(da)
for i in a:p[da[i]]+=1
for i in range(1,len(p)):p[i]+=p[i-1]
for i in a[:-1]:
  j=bisect_right(b,i-d)-1
  print(p[j]-1)
0