結果
| 問題 | No.3391 Line up Dominoes |
| コンテスト | |
| ユーザー |
zjsdut
|
| 提出日時 | 2026-09-01 21:19:23 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 433 ms / 3,000 ms |
| + 229µs | |
| コード長 | 1,147 bytes |
| 記録 | |
| コンパイル時間 | 2,528 ms |
| コンパイル使用メモリ | 342,656 KB |
| 実行使用メモリ | 9,788 KB |
| 最終ジャッジ日時 | 2026-09-01 21:19:38 |
| 合計ジャッジ時間 | 13,871 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
/**
* author: zjs
* created: 01.09.2026 20:03:03
**/
#include <bits/stdc++.h>
#include <cassert> // <bits/stdc++.h> does not include cassert since GCC 16.
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a.begin(), a.end());
vector<int> l(n), r(n);
for (int i = 0, j = 0; i < n; i++) {
while (a[j] + k < a[i])
j++;
l[i] = j;
}
for (int i = 0, j = 0; i < n; i++) {
while (j < n && !(a[i] + k < a[j]))
j++;
r[i] = j;
}
const int mod = 998244353;
vector<int> sum(n + 1);
for (int i = 0; i < n; i++)
sum[i + 1] = sum[i] + 1;
for (int i = 0; i < m - 1; i++) {
vector<int> nsum(n + 1);
for (int j = 0; j < n; j++) {
nsum[j + 1] = ((long long) nsum[j] + sum[r[j]] - sum[l[j]]) % mod;
}
sum = nsum;
}
if (sum[n] < 0)
sum[n] += mod;
cout << sum[n] << '\n';
}
zjsdut