#include <bits/stdc++.h>
using namespace std;
#define lg long long
const lg N = 2e5+5, MOD = 1e9+7;
lg v[N], fact[N];
lg fast_power(lg n, lg k)
{
lg ans = 1;
while(k)
{
if((k&1))
{
ans = (ans*n)%MOD;
}
n = (n*n)%MOD;
k >>= 1;
}
return ans;
}
lg C(lg n, lg r)
{
lg ans = fact[n];
ans = (ans*fast_power(fact[r], MOD-2))%MOD;
ans = (ans*fast_power(fact[n-r], MOD-2))%MOD;
return ans;
}
lg dp[51][51][int(1e4+5)], fr[int(1e4+5)];
int main()
{
lg n, l;
cin >> n >> l;
fact[0] = 1;
for(lg i = 1; i <= 1e5; i++) fact[i] = (fact[i-1]*i)%MOD;
for(int i = 1; i <= n; i++) cin >> v[i];
sort(v+1, v+n+1);
dp[1][1][1] = 1;
for(int i = 1; i < n; i++)
{
for(int j = 1; j <= n; j++)
{
for(int k = 0; k <= l; k++)
{
dp[i+1][j][k+v[i+1]] = (dp[i+1][j][k+v[i+1]]+(dp[i][j][k]*j*2ll)%MOD)%MOD;
if(j)
{
dp[i+1][j-1][k+v[i+1]*2] = (dp[i+1][j-1][k+v[i+1]*2]+(dp[i][j][k]*(j*(j-1))%MOD)%MOD)%MOD;
}
dp[i+1][j+1][k] = (dp[i+1][j+1][k]+dp[i][j][k])%MOD;
}
}
}
for(int i = 0; i <= l; i++) fr[i] = dp[n][1][i];
lg ans = 0;
for(lg i = 0; i <= l; i++)
{
lg cur = fr[i];
// cout << cur << ' ' << l-i+n << ' ' << n << '\n';
cur = (cur*C(l-i+n, n))%MOD;
ans = (ans+cur)%MOD;
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
236 ms |
199664 KB |
Output is correct |
2 |
Correct |
7 ms |
15960 KB |
Output is correct |
3 |
Correct |
13 ms |
13648 KB |
Output is correct |
4 |
Correct |
5 ms |
5980 KB |
Output is correct |
5 |
Correct |
15 ms |
17284 KB |
Output is correct |
6 |
Correct |
71 ms |
66388 KB |
Output is correct |
7 |
Correct |
145 ms |
183892 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
74 ms |
104588 KB |
Output is correct |
10 |
Correct |
2 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
12888 KB |
Output is correct |
2 |
Correct |
3 ms |
4952 KB |
Output is correct |
3 |
Correct |
13 ms |
12888 KB |
Output is correct |
4 |
Correct |
4 ms |
5720 KB |
Output is correct |
5 |
Correct |
13 ms |
12888 KB |
Output is correct |
6 |
Correct |
4 ms |
6492 KB |
Output is correct |
7 |
Correct |
13 ms |
12888 KB |
Output is correct |
8 |
Correct |
3 ms |
5720 KB |
Output is correct |
9 |
Correct |
4 ms |
6236 KB |
Output is correct |
10 |
Correct |
3 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
7004 KB |
Output is correct |
3 |
Correct |
6 ms |
10588 KB |
Output is correct |
4 |
Correct |
4 ms |
7516 KB |
Output is correct |
5 |
Correct |
6 ms |
10588 KB |
Output is correct |
6 |
Correct |
2 ms |
6236 KB |
Output is correct |
7 |
Correct |
6 ms |
10556 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
4 ms |
8028 KB |
Output is correct |
10 |
Correct |
2 ms |
5212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
236 ms |
199664 KB |
Output is correct |
2 |
Correct |
7 ms |
15960 KB |
Output is correct |
3 |
Correct |
13 ms |
13648 KB |
Output is correct |
4 |
Correct |
5 ms |
5980 KB |
Output is correct |
5 |
Correct |
15 ms |
17284 KB |
Output is correct |
6 |
Correct |
71 ms |
66388 KB |
Output is correct |
7 |
Correct |
145 ms |
183892 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
74 ms |
104588 KB |
Output is correct |
10 |
Correct |
2 ms |
4444 KB |
Output is correct |
11 |
Correct |
13 ms |
12888 KB |
Output is correct |
12 |
Correct |
3 ms |
4952 KB |
Output is correct |
13 |
Correct |
13 ms |
12888 KB |
Output is correct |
14 |
Correct |
4 ms |
5720 KB |
Output is correct |
15 |
Correct |
13 ms |
12888 KB |
Output is correct |
16 |
Correct |
4 ms |
6492 KB |
Output is correct |
17 |
Correct |
13 ms |
12888 KB |
Output is correct |
18 |
Correct |
3 ms |
5720 KB |
Output is correct |
19 |
Correct |
4 ms |
6236 KB |
Output is correct |
20 |
Correct |
3 ms |
4444 KB |
Output is correct |
21 |
Correct |
6 ms |
10584 KB |
Output is correct |
22 |
Correct |
3 ms |
7004 KB |
Output is correct |
23 |
Correct |
6 ms |
10588 KB |
Output is correct |
24 |
Correct |
4 ms |
7516 KB |
Output is correct |
25 |
Correct |
6 ms |
10588 KB |
Output is correct |
26 |
Correct |
2 ms |
6236 KB |
Output is correct |
27 |
Correct |
6 ms |
10556 KB |
Output is correct |
28 |
Correct |
2 ms |
5212 KB |
Output is correct |
29 |
Correct |
4 ms |
8028 KB |
Output is correct |
30 |
Correct |
2 ms |
5212 KB |
Output is correct |
31 |
Correct |
243 ms |
199628 KB |
Output is correct |
32 |
Correct |
148 ms |
137040 KB |
Output is correct |
33 |
Correct |
234 ms |
199760 KB |
Output is correct |
34 |
Correct |
50 ms |
49488 KB |
Output is correct |
35 |
Correct |
244 ms |
200016 KB |
Output is correct |
36 |
Correct |
16 ms |
17752 KB |
Output is correct |
37 |
Correct |
239 ms |
199760 KB |
Output is correct |
38 |
Correct |
42 ms |
46412 KB |
Output is correct |
39 |
Incorrect |
240 ms |
199768 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |