結果

問題 No.2757 Pin Game
ユーザー 👑 timitimi
提出日時 2024-05-17 21:30:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 130,832 KB
最終ジャッジ日時 2024-05-17 21:30:52
合計ジャッジ時間 1,642 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
54,084 KB
testcase_01 AC 37 ms
54,820 KB
testcase_02 AC 36 ms
55,348 KB
testcase_03 AC 35 ms
54,068 KB
testcase_04 AC 149 ms
130,832 KB
testcase_05 AC 131 ms
126,916 KB
testcase_06 AC 40 ms
55,072 KB
testcase_07 AC 39 ms
53,832 KB
testcase_08 AC 37 ms
54,268 KB
testcase_09 AC 36 ms
55,556 KB
testcase_10 AC 81 ms
91,496 KB
testcase_11 AC 87 ms
91,416 KB
権限があれば一括ダウンロードができます

ソースコード

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