#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define sz(v) (int)v.size()
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define compact(v) v.erase(unique(ALL(v)), end(v))
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (int)(b); i--)
#define BIT(mask,i) ((mask>>(i))&1)
#define MASK(a) (1LL << (a))
#define lwb lower_bound
#define upb upper_bound
#define dbg(x) "[" #x " = " << (x) << "]"
#define file(task) if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
template<typename T>
bool minimize (T& a, const T& b) {
if (a > b) return a = b, true;
return false;
}
template<typename T>
bool maximize (T& a, const T& b) {
if (a < b) return a = b, true;
return false;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vpi = vector<pii>;
using vpl = vector<pll>;
const int maxn = 105;
const int mod = 1e9 + 7;
int n, L;
int r[maxn];
int fact[20005], inv_fact[20005];
int dp[55][55][10005];
int iPow(int x, int y) {
if (y == 0) return 1;
if (y == 1) return x;
int c = iPow(x, y / 2);
if (y & 1) return 1LL * c * c % mod * x % mod;
else return 1LL * c * c % mod;
}
inline int C(int n, int k) {
return 1LL * fact[n] * inv_fact[n - k] % mod * inv_fact[k] % mod;
}
void add(int &x, const int y) {
x+= y;
if (x >= mod) x-= mod;
}
void solve() {
cin >> n >> L;
FOR(i, 1, n) cin >> r[i];
fact[0] = 1;
FOR(i, 1, 20000) fact[i] = 1LL * fact[i - 1] * i % mod;
inv_fact[20000] = iPow(fact[20000], mod - 2);
FORD(i, 19999, 0) inv_fact[i] = 1LL * inv_fact[i + 1] * (i + 1) % mod;
sort(r + 1, r + 1 + n);
dp[1][1][1] = 1;
/// goi dp[i][j][d] : xet tu 1 ... i co j nhom va tong khoang cach la d
FOR(i, 1, n) FOR(j, 0, i) FOR(d, 1, L) {
add(dp[i + 1][j + 1][d + 1], 1LL * (j + 1) * dp[i][j][d] % mod);
if(d + r[i + 1] <= L){
add(dp[i + 1][j][d + r[i + 1]], 1LL * 2 * j % mod * dp[i][j][d] % mod);
}
if(j > 1 && d + 2 * r[i + 1] - 1 <= L){
add(dp[i + 1][j - 1][d + 2 * r[i + 1] - 1], 1LL * dp[i][j][d] * (j - 1) % mod);
}
}
int ans = 0;
FOR(i, 1, L) {
add(ans, 1LL * dp[n][1][i] * C(L - i + n, n) % mod);
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
file("kieuoanh");
int tc = 1; // cin >> tc;
while (tc--) solve();
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:22:55: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | #define file(task) if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:109:5: note: in expansion of macro 'file'
109 | file("kieuoanh");
| ^~~~
Main.cpp:22:88: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | #define file(task) if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:109:5: note: in expansion of macro 'file'
109 | file("kieuoanh");
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |