結果

問題 No.3391 Line up Dominoes
コンテスト
ユーザー sasa8uyauya
提出日時 2025-11-28 22:16:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,870 ms / 3,000 ms
コード長 381 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 88,936 KB
最終ジャッジ日時 2025-11-28 22:17:36
合計ジャッジ時間 35,496 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
pl=[0]*n
pr=[0]*n
l=0
r=0
for i in range(n):
  while l<i and a[i]-a[l]>k:
    l+=1
  r=max(r,i)
  while r+1<n and a[r+1]-a[i]<=k:
    r+=1
  pl[i],pr[i]=l,r
q=[1]*n
M=998244353
for _ in range(1,m):
  q+=[0]
  for i in range(n):
    q[i]+=q[i-1]
  q=[(q[pr[i]]-q[pl[i]-1])%M for i in range(n)]
print(sum(q)%M)
0