#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(NULL)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
const ll Mod = 1e9 + 7;
int n, l;
int a[111];
ll dp[3][111][111][1010];
int main() {
fast;
cin >> n >> l;
for(int i=1; i<=n; i++) cin >> a[i];
sort(a+1, a+n+1);
dp[0][1][1][0] = 1;
dp[2][1][1][0] = 1;
dp[1][1][1][0] = 2;
for(int i=1; i<n; i++) {
for(int j=1; j<=i; j++) {
for(int k=0; k<=l; k++) {
for(int t=0; t<=2; t++) {
int p = k + (a[i+1] - a[i]) * (2 * j - t);
if(p > l) continue;
dp[t][i+1][j+1][p] += dp[t][i][j][k] * (j - t + 1);
dp[t][i+1][j+1][p] %= Mod;
dp[t][i+1][j][p] += dp[t][i][j][k] * (2 * j - t);
dp[t][i+1][j][p] %= Mod;
dp[t][i+1][j-1][p] += dp[t][i][j][k] * (j-1);
dp[t][i+1][j-1][p] %= Mod;
if(t < 2) {
dp[t+1][i+1][j][p] += dp[t][i][j][k] * (2 - t);
dp[t+1][i+1][j][p] %= Mod;
dp[t+1][i+1][j+1][p] += dp[t][i][j][k] * (2 - t);
dp[t+1][i+1][j+1][p] %= Mod;
}
}
}
}
}
ll ans = 0;
for(int i=0; i<=l; i++) ans += dp[2][n][1][i];
cout << ans % Mod;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
1280 KB |
Output is correct |
6 |
Correct |
1 ms |
1152 KB |
Output is correct |
7 |
Correct |
1 ms |
1024 KB |
Output is correct |
8 |
Correct |
1 ms |
896 KB |
Output is correct |
9 |
Correct |
2 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1536 KB |
Output is correct |
2 |
Correct |
2 ms |
1536 KB |
Output is correct |
3 |
Correct |
2 ms |
1792 KB |
Output is correct |
4 |
Correct |
2 ms |
1536 KB |
Output is correct |
5 |
Correct |
2 ms |
1664 KB |
Output is correct |
6 |
Correct |
2 ms |
1792 KB |
Output is correct |
7 |
Correct |
1 ms |
1664 KB |
Output is correct |
8 |
Correct |
2 ms |
1792 KB |
Output is correct |
9 |
Correct |
2 ms |
1792 KB |
Output is correct |
10 |
Correct |
1 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
1280 KB |
Output is correct |
6 |
Correct |
1 ms |
1152 KB |
Output is correct |
7 |
Correct |
1 ms |
1024 KB |
Output is correct |
8 |
Correct |
1 ms |
896 KB |
Output is correct |
9 |
Correct |
2 ms |
1280 KB |
Output is correct |
10 |
Correct |
1 ms |
1024 KB |
Output is correct |
11 |
Correct |
1 ms |
1536 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1792 KB |
Output is correct |
14 |
Correct |
2 ms |
1536 KB |
Output is correct |
15 |
Correct |
2 ms |
1664 KB |
Output is correct |
16 |
Correct |
2 ms |
1792 KB |
Output is correct |
17 |
Correct |
1 ms |
1664 KB |
Output is correct |
18 |
Correct |
2 ms |
1792 KB |
Output is correct |
19 |
Correct |
2 ms |
1792 KB |
Output is correct |
20 |
Correct |
1 ms |
1536 KB |
Output is correct |
21 |
Correct |
7 ms |
8832 KB |
Output is correct |
22 |
Correct |
117 ms |
76024 KB |
Output is correct |
23 |
Correct |
157 ms |
95096 KB |
Output is correct |
24 |
Correct |
149 ms |
104184 KB |
Output is correct |
25 |
Correct |
156 ms |
94456 KB |
Output is correct |
26 |
Correct |
147 ms |
94456 KB |
Output is correct |
27 |
Correct |
88 ms |
84216 KB |
Output is correct |
28 |
Correct |
97 ms |
91128 KB |
Output is correct |
29 |
Correct |
147 ms |
114552 KB |
Output is correct |
30 |
Correct |
154 ms |
94968 KB |
Output is correct |