#define _GLIBCXX_DEBUG #include #include using namespace std; using mint = atcoder::modint998244353; using T = tuple; int main() { map memo; auto f = [&](auto f, int n, int m, int k) { if(memo.count(T(n, m, k))) return memo[T(n, m, k)]; if(n == 0 or m < 0) return memo[T(n, m, k)] = (m ? 0 : 1); if(n * k < m) return memo[T(n, m, k)] = 0; return memo[T(n, m, k)] = f(f, n - 1, m, k) + f(f, n, m - n, k - 1); }; int n, k; cin >> n >> k; vector a(n, 0), cnt(n, 0); for(auto& v : a) cin >> v; if(k > n * (n - 1) / 2) { puts("0"); return 0; } sort(a.begin(), a.end()); int now = 0; for(int i = 0; i < n - 1; i++) { cnt[now]++; if(a[i] != a[i + 1]) now++; } cnt[now]++; vector dp(n + 1, vector(k + 1, mint(0))); dp[0][0] = 1; int cum = 0; for(int i = 0; i < n; i++) { for(int j = 0; j <= k; j++) for(int l = 0; l <= min(cnt[i] * cum, j); l++) dp[i + 1][j] += dp[i][j - l] * f(f, cnt[i], l, cum); cum += cnt[i]; } cout << dp.back()[k].val() << '\n'; return 0; }