結果
| 問題 | No.3391 Line up Dominoes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-29 00:02:34 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 328 ms / 3,000 ms |
| コード長 | 841 bytes |
| コンパイル時間 | 5,793 ms |
| コンパイル使用メモリ | 335,228 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-11-29 00:02:50 |
| 合計ジャッジ時間 | 14,130 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
short n, m;
int k;
cin >> n >> m >> k;
vector<int> a(n);
for(auto &&v : a) cin >> v;
sort(a.begin(), a.end());
vector<pair<short,short>> b(n);
for(short i = 0, l = 0, r = 0; i < n; i++){
while(l < n && a[l] < a[i] - k) l++;
while(r < n && a[r] <= a[i] + k) r++;
b[i] = make_pair(l, r);
}
vector<mint> dp(n + 1), ndp(n + 1);
iota(dp.begin(), dp.end(), mint::raw(0));
for(short i = 1; i < m; i++){
for(short j = 0; j < n; j++){
ndp[j + 1] = ndp[j] + dp[b[j].second] - dp[b[j].first];
}
swap(dp, ndp);
}
cout << dp[n].val() << '\n';
}