結果

問題 No.3391 Line up Dominoes
コンテスト
ユーザー Tehom
提出日時 2025-11-28 23:02:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,042 bytes
コンパイル時間 4,472 ms
コンパイル使用メモリ 260,112 KB
実行使用メモリ 402,216 KB
最終ジャッジ日時 2025-11-28 23:02:31
合計ジャッジ時間 9,535 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other MLE * 1 -- * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()

template <typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;}
template <typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;} return false;}

using mint=modint998244353;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll n,m,k; cin >> n >> m >> k;
  vector<ll> a(n);
  rep(i,0,n) cin >> a[i];
  vector<int> left(n),right(n);
  sort(all(a));
  rep(i,0,n){
    left[i]=lower_bound(all(a),a[i]-k)-a.begin();
    right[i]=upper_bound(all(a),a[i]+k)-a.begin();
  }
  vector<vector<mint>> dp(n+1,vector<mint>(m));
  rep(i,0,n) dp[i][0]=1;
  rep(j,1,m){
    rep(i,0,n){
      dp[left[i]][j]+=dp[i][j-1];
      dp[right[i]][j]-=dp[i][j-1];
    }
    rep(i,0,n) dp[i+1][j]+=dp[i][j];
  }
  mint ans=0;
  rep(i,0,n) ans+=dp[i][m-1];
  cout << ans.val() << endl;
}
0