結果

問題 No.2757 Pin Game
ユーザー timi
提出日時 2024-05-17 21:30:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 82,008 KB
実行使用メモリ 130,428 KB
最終ジャッジ日時 2024-12-20 13:15:13
合計ジャッジ時間 2,363 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int, input().split())
X=list(map(int, input().split()))

from collections import deque
d=deque()

for i in range(N):
  if i==0:
    d.append((X[i],1))
  else:
    x=X[i]
    ma=1
    while d and x-d[0][0]>=M:
      _,c=d.popleft()
      ma=max(ma,c+1)
    d.append((x,ma)) 

ans=0
while d:
  _,c=d.popleft()
  ans=max(ans,c)
print(ans)
0