#include <bits/stdc++.h>
using namespace std;
#define int int64_t
const int MOD = 1e9+7, Z = 1e2 + 1, LIM = 1e3 + 1;
int N, L, A[Z], dp[Z][LIM][3], prv[Z][LIM][3];
#define push(X, Y, Z, VAL) (dp[X][Y][Z] += VAL) %= MOD;
int32_t main() {
cin >> N >> L;
for(int i = 0; i < N; ++i)
cin >> A[i];
sort(A, A + N);
dp[1][0][0] = 1;
dp[1][0][1] = 2;
if(N < 2)
dp[1][0][2] = 1;
for(int c = 1; c < N; ++c) {
swap(prv, dp);
memset(dp, 0, sizeof dp);
for(int i = 1; i < N; ++i) {
for(int j = 0; j < L; ++j) {
for(int k = 0; k < 3; ++k) {
int diff = j + (A[c] - A[c-1]) * (2 * i - k);
if(diff >= LIM) continue;
push(i + 1, diff, k, prv[i][j][k] * (i + 1 - k));
push(i - 1, diff, k, prv[i][j][k] * (i - 1));
push(i + 0, diff, k, prv[i][j][k] * (2 * i - k));
if(k < 2) {
push(i + 1, diff, k + 1, prv[i][j][k] * (1 + !k));
push(i + 0, diff, k + 1, prv[i][j][k] * (1 + !k));
}
}
}
}
}
int ans {};
for(int i = 0; i <= L; ++i)
(ans += dp[1][i][2]) %= MOD;
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
4 ms |
5012 KB |
Output is correct |
3 |
Correct |
5 ms |
5044 KB |
Output is correct |
4 |
Correct |
7 ms |
5040 KB |
Output is correct |
5 |
Correct |
7 ms |
4948 KB |
Output is correct |
6 |
Correct |
7 ms |
4948 KB |
Output is correct |
7 |
Correct |
5 ms |
5040 KB |
Output is correct |
8 |
Correct |
6 ms |
5048 KB |
Output is correct |
9 |
Correct |
6 ms |
4948 KB |
Output is correct |
10 |
Correct |
6 ms |
4948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
5048 KB |
Output is correct |
2 |
Correct |
8 ms |
5040 KB |
Output is correct |
3 |
Correct |
8 ms |
5056 KB |
Output is correct |
4 |
Correct |
10 ms |
5044 KB |
Output is correct |
5 |
Correct |
8 ms |
4948 KB |
Output is correct |
6 |
Correct |
8 ms |
4956 KB |
Output is correct |
7 |
Correct |
8 ms |
5072 KB |
Output is correct |
8 |
Correct |
9 ms |
5048 KB |
Output is correct |
9 |
Correct |
10 ms |
5052 KB |
Output is correct |
10 |
Correct |
7 ms |
4948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
4 ms |
5012 KB |
Output is correct |
3 |
Correct |
5 ms |
5044 KB |
Output is correct |
4 |
Correct |
7 ms |
5040 KB |
Output is correct |
5 |
Correct |
7 ms |
4948 KB |
Output is correct |
6 |
Correct |
7 ms |
4948 KB |
Output is correct |
7 |
Correct |
5 ms |
5040 KB |
Output is correct |
8 |
Correct |
6 ms |
5048 KB |
Output is correct |
9 |
Correct |
6 ms |
4948 KB |
Output is correct |
10 |
Correct |
6 ms |
4948 KB |
Output is correct |
11 |
Correct |
8 ms |
5048 KB |
Output is correct |
12 |
Correct |
8 ms |
5040 KB |
Output is correct |
13 |
Correct |
8 ms |
5056 KB |
Output is correct |
14 |
Correct |
10 ms |
5044 KB |
Output is correct |
15 |
Correct |
8 ms |
4948 KB |
Output is correct |
16 |
Correct |
8 ms |
4956 KB |
Output is correct |
17 |
Correct |
8 ms |
5072 KB |
Output is correct |
18 |
Correct |
9 ms |
5048 KB |
Output is correct |
19 |
Correct |
10 ms |
5052 KB |
Output is correct |
20 |
Correct |
7 ms |
4948 KB |
Output is correct |
21 |
Correct |
21 ms |
5048 KB |
Output is correct |
22 |
Correct |
145 ms |
5044 KB |
Output is correct |
23 |
Correct |
181 ms |
5032 KB |
Output is correct |
24 |
Correct |
185 ms |
5032 KB |
Output is correct |
25 |
Correct |
177 ms |
4948 KB |
Output is correct |
26 |
Correct |
159 ms |
5024 KB |
Output is correct |
27 |
Correct |
98 ms |
5028 KB |
Output is correct |
28 |
Correct |
138 ms |
5028 KB |
Output is correct |
29 |
Correct |
196 ms |
4948 KB |
Output is correct |
30 |
Correct |
189 ms |
4948 KB |
Output is correct |