#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int dp[128][128][1024][3];
int s[128];
const int mod = 1e9 + 7;
void add(int &x,int y) {
x += y;
if (x >= mod)
x -= mod;
}
int pr(int x,int y) {
return 1ll * x * y % mod;
}
int n,l;
int main(void) {
cin>>n>>l;
for (int i = 1;i <= n;++i)
cin>>s[i];
sort(s + 1,s + 1 + n);
for (int i = n - 1;i;--i)
s[i + 1] -= s[i];
if (n == 1)
return puts("1") * 0;
if (n == 2)
return puts(s[2] <= l ? "2" : "0") * 0;
for (int i = 1;i <= n;++i)
cerr << s[i] << " \n"[i == n];
dp[0][0][0][0] = 1;
for (int i = 0;i < n;++i)
for (int j = 0;j <= i;++j)
for (int k = 0;k <= l;++k)
for (int t = 0;t < 3;++t) {
int ns = k + s[i + 1] * (2 * j - t);
const int C = dp[i][j][k][t];
if (ns > l)
continue;
add(dp[i + 1][j + 1][ns][t],pr(j + 1 - t,C));
add(dp[i + 1][j][ns][t],pr(2 * j - t,C));
if (j > 0)
add(dp[i + 1][j - 1][ns][t],pr(j - 1,C));
add(dp[i + 1][j + 1][ns][t + 1],pr(2 - t,C));
add(dp[i + 1][j][ns][t + 1],pr(2 - t,C));
}
int ans = 0;
for (int i = 0;i <= l;++i)
add(ans,dp[n][1][i][2]);
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Incorrect |
4 ms |
488 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Incorrect |
4 ms |
488 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |