#include #include using namespace std; using namespace atcoder; using mint = modint998244353; int main() { int n, k; cin >> n >> k; vector a(n); for (auto &&x : a) { cin >> x; } sort(a.begin(), a.end()); auto acopy = a; acopy.erase(unique(acopy.begin(), acopy.end()), acopy.end()); for (auto &&x : a) { x = lower_bound(acopy.begin(), acopy.end(), x) - acopy.begin(); } vector acount(n); for (auto &&x : a) { acount.at(x)++; } vector dp(n + 1, vector(k + 1)); dp.at(0).at(0) = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= k; j++) { for (int jnew = j; jnew <= min(k, j + i); jnew++) { dp.at(i + 1).at(jnew) += dp.at(i).at(j); } } } auto ans = dp.at(n); for (int i = 0; i < n; i++) { int64_t d = acount.at(i); if (d <= 1) { continue; } for (int j = 0; j <= k; j++) { mint x = ans.at(j); for (int jnew = j + 1; jnew <= min(int64_t(k), j + d * (d - 1) / 2); jnew++) { ans.at(jnew) -= x * dp.at(d).at(jnew - j); } } } cout << ans.at(k).val() << endl; return 0; }