#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
const int mod = 1e9 + 7;
int n, l;
int a[101];
int dp[101][101][1001][2][2];
void add(int i, int j, int k, int d, int a, int b, llong p) {
k += ((j << 1) + a + b) * d;
if (j < 0) return;
if (l < k) return;
dp[i][j][k][a][b] += p % mod;
dp[i][j][k][a][b] %= mod;
}
int main() {
scanf("%d%d", &n, &l);
if (n == 1) {
printf("1\n");
return 0;
}
for (int i = 0; i < n; ++i) {
scanf("%d", a + i);
}
sort(a, a + n);
dp[0][0][0][0][0] = 1;
for (int i = 0; i + 1 < n; ++i) {
int d = a[i + 1] - a[i];
for (int j = 0; j <= i; ++j) {
for (int k = 0; k <= l; ++k) {
llong v;
//0 0
v = dp[i][j][k][0][0];
add(i + 1, j, k, d, 1, 0, v);
add(i + 1, j, k, d, 0, 1, v);
add(i + 1, j + 1, k, d, 0, 0, v);
add(i + 1, j, k, d, 0, 0, v * (j << 1));
add(i + 1, j - 1, k, d, 0, 0, v * j * (j - 1));
add(i + 1, j - 1, k, d, 0, 1, v * j);
add(i + 1, j - 1, k, d, 1, 0, v * j);
//0 1
v = dp[i][j][k][0][1];
add(i + 1, j, k, d, 1, 1, v);
add(i + 1, j, k, d, 0, 1, v);
add(i + 1, j + 1, k, d, 0, 1, v);
add(i + 1, j, k, d, 0, 1, v * (j << 1));
add(i + 1, j - 1, k, d, 0, 1, v * j * (j - 1));
add(i + 1, j - 1, k, d, 0, 1, v * j);
add(i + 1, j - 1, k, d, 1, 1, v * j);
//1 0
v = dp[i][j][k][1][0];
add(i + 1, j, k, d, 1, 0, v);
add(i + 1, j, k, d, 1, 1, v);
add(i + 1, j + 1, k, d, 1, 0, v);
add(i + 1, j, k, d, 1, 0, v * (j << 1));
add(i + 1, j - 1, k, d, 1, 0, v * j * (j - 1));
add(i + 1, j - 1, k, d, 1, 1, v * j);
add(i + 1, j - 1, k, d, 1, 0, v * j);
//1 1
v = dp[i][j][k][1][1];
add(i + 1, j, k, d, 1, 1, v);
add(i + 1, j, k, d, 1, 1, v);
add(i + 1, j + 1, k, d, 1, 1, v);
add(i + 1, j, k, d, 1, 1, v * (j << 1));
add(i + 1, j - 1, k, d, 1, 1, v * j * (j - 1));
add(i + 1, j - 1, k, d, 1, 1, v * j);
add(i + 1, j - 1, k, d, 1, 1, v * j);
}
}
}
int ret = 0;
for (int i = 0; i <= l; ++i) {
ret += dp[n - 1][0][i][1][1];
ret %= mod;
ret += dp[n - 1][0][i][0][1];
ret %= mod;
ret += dp[n - 1][0][i][1][0];
ret %= mod;
}
printf("%d\n", ret);
return 0;
}
Compilation message
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &l);
~~~~~^~~~~~~~~~~~~~~~
skyscraper.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", a + i);
~~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
908 KB |
Output is correct |
6 |
Correct |
5 ms |
908 KB |
Output is correct |
7 |
Correct |
3 ms |
908 KB |
Output is correct |
8 |
Correct |
2 ms |
908 KB |
Output is correct |
9 |
Correct |
6 ms |
924 KB |
Output is correct |
10 |
Correct |
3 ms |
924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
956 KB |
Output is correct |
2 |
Correct |
3 ms |
956 KB |
Output is correct |
3 |
Correct |
3 ms |
956 KB |
Output is correct |
4 |
Correct |
4 ms |
956 KB |
Output is correct |
5 |
Correct |
4 ms |
996 KB |
Output is correct |
6 |
Correct |
3 ms |
1124 KB |
Output is correct |
7 |
Correct |
2 ms |
1124 KB |
Output is correct |
8 |
Correct |
4 ms |
1124 KB |
Output is correct |
9 |
Correct |
4 ms |
1124 KB |
Output is correct |
10 |
Correct |
3 ms |
1124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
908 KB |
Output is correct |
6 |
Correct |
5 ms |
908 KB |
Output is correct |
7 |
Correct |
3 ms |
908 KB |
Output is correct |
8 |
Correct |
2 ms |
908 KB |
Output is correct |
9 |
Correct |
6 ms |
924 KB |
Output is correct |
10 |
Correct |
3 ms |
924 KB |
Output is correct |
11 |
Correct |
2 ms |
956 KB |
Output is correct |
12 |
Correct |
3 ms |
956 KB |
Output is correct |
13 |
Correct |
3 ms |
956 KB |
Output is correct |
14 |
Correct |
4 ms |
956 KB |
Output is correct |
15 |
Correct |
4 ms |
996 KB |
Output is correct |
16 |
Correct |
3 ms |
1124 KB |
Output is correct |
17 |
Correct |
2 ms |
1124 KB |
Output is correct |
18 |
Correct |
4 ms |
1124 KB |
Output is correct |
19 |
Correct |
4 ms |
1124 KB |
Output is correct |
20 |
Correct |
3 ms |
1124 KB |
Output is correct |
21 |
Correct |
10 ms |
3300 KB |
Output is correct |
22 |
Correct |
386 ms |
47904 KB |
Output is correct |
23 |
Correct |
553 ms |
55324 KB |
Output is correct |
24 |
Correct |
449 ms |
57044 KB |
Output is correct |
25 |
Correct |
537 ms |
57044 KB |
Output is correct |
26 |
Correct |
382 ms |
57044 KB |
Output is correct |
27 |
Correct |
161 ms |
57044 KB |
Output is correct |
28 |
Correct |
206 ms |
57044 KB |
Output is correct |
29 |
Correct |
372 ms |
57044 KB |
Output is correct |
30 |
Correct |
452 ms |
57044 KB |
Output is correct |