// I am.
#include<bits/stdc++.h>
using namespace std;
const int N = 109, L = 1009, Mod = 1e9 + 7;
int n, l, A[N], dp[N][L][2][2], dpt[N][L][2][2];
inline void Add(int j, int k, int s, int e, int val)
{
dp[j][k][s][e] += val;
if (dp[j][k][s][e] >= Mod)
dp[j][k][s][e] -= Mod;
}
int main()
{
scanf("%d%d", &n, &l);
for (int i = 0; i < n; i ++)
scanf("%d", &A[i]);
sort(A, A + n);
dp[1][0][0][0] = dp[1][0][0][1] = 1;
dp[1][0][1][0] = dp[1][0][1][1] = 1;
for (int i = 0; i < n - 1; i ++)
{
memcpy(dpt, dp, sizeof(dp));
memset(dp, 0, sizeof(dp));
for (int j = 1; j <= i + 1; j ++)
for (int k = 0; k <= l; k ++)
for (int s = 0; s <= 1; s ++)
for (int e = 0; e <= 1; e ++)
{
int _k = k + (j + j - s - e) * (A[i + 1] - A[i]);
if (_k > l)
continue;
Add(j - 1, _k, s, e, dpt[j][k][s][e] * 1LL * (j - 1) % Mod);
Add(j + 1, _k, s, e, dpt[j][k][s][e] * 1LL * (j - 1) % Mod);
Add(j, _k, s, e, dpt[j][k][s][e] * 2LL * (j - 1) % Mod);
if (!s)
{
Add(j, _k, 1, e, dpt[j][k][s][e]);
Add(j + 1, _k, 1, e, dpt[j][k][s][e]);
Add(j, _k, 0, e, dpt[j][k][s][e]);
Add(j + 1, _k, 0, e, dpt[j][k][s][e]);
}
if (!e)
{
Add(j, _k, s, 1, dpt[j][k][s][e]);
Add(j + 1, _k, s, 1, dpt[j][k][s][e]);
Add(j, _k, s, 0, dpt[j][k][s][e]);
Add(j + 1, _k, s, 0, dpt[j][k][s][e]);
}
}
}
int tot = 0;
for (int i = 0; i <= l; i ++)
tot = (tot + dp[1][i][1][1]) % Mod;
return !printf("%d\n", tot);
}
Compilation message
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:14: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:16: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 |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
3840 KB |
Output is correct |
3 |
Correct |
6 ms |
3712 KB |
Output is correct |
4 |
Correct |
7 ms |
3712 KB |
Output is correct |
5 |
Correct |
8 ms |
3840 KB |
Output is correct |
6 |
Correct |
8 ms |
3840 KB |
Output is correct |
7 |
Correct |
5 ms |
3840 KB |
Output is correct |
8 |
Correct |
7 ms |
3840 KB |
Output is correct |
9 |
Correct |
8 ms |
3840 KB |
Output is correct |
10 |
Correct |
7 ms |
3840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
3840 KB |
Output is correct |
2 |
Correct |
9 ms |
3840 KB |
Output is correct |
3 |
Correct |
8 ms |
3840 KB |
Output is correct |
4 |
Correct |
9 ms |
3712 KB |
Output is correct |
5 |
Correct |
9 ms |
3712 KB |
Output is correct |
6 |
Correct |
9 ms |
3840 KB |
Output is correct |
7 |
Correct |
8 ms |
3840 KB |
Output is correct |
8 |
Correct |
8 ms |
3840 KB |
Output is correct |
9 |
Correct |
8 ms |
3712 KB |
Output is correct |
10 |
Correct |
8 ms |
3840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
3840 KB |
Output is correct |
3 |
Correct |
6 ms |
3712 KB |
Output is correct |
4 |
Correct |
7 ms |
3712 KB |
Output is correct |
5 |
Correct |
8 ms |
3840 KB |
Output is correct |
6 |
Correct |
8 ms |
3840 KB |
Output is correct |
7 |
Correct |
5 ms |
3840 KB |
Output is correct |
8 |
Correct |
7 ms |
3840 KB |
Output is correct |
9 |
Correct |
8 ms |
3840 KB |
Output is correct |
10 |
Correct |
7 ms |
3840 KB |
Output is correct |
11 |
Correct |
8 ms |
3840 KB |
Output is correct |
12 |
Correct |
9 ms |
3840 KB |
Output is correct |
13 |
Correct |
8 ms |
3840 KB |
Output is correct |
14 |
Correct |
9 ms |
3712 KB |
Output is correct |
15 |
Correct |
9 ms |
3712 KB |
Output is correct |
16 |
Correct |
9 ms |
3840 KB |
Output is correct |
17 |
Correct |
8 ms |
3840 KB |
Output is correct |
18 |
Correct |
8 ms |
3840 KB |
Output is correct |
19 |
Correct |
8 ms |
3712 KB |
Output is correct |
20 |
Correct |
8 ms |
3840 KB |
Output is correct |
21 |
Correct |
17 ms |
3840 KB |
Output is correct |
22 |
Correct |
303 ms |
3800 KB |
Output is correct |
23 |
Correct |
382 ms |
3840 KB |
Output is correct |
24 |
Correct |
336 ms |
3832 KB |
Output is correct |
25 |
Correct |
375 ms |
3932 KB |
Output is correct |
26 |
Correct |
346 ms |
3804 KB |
Output is correct |
27 |
Correct |
137 ms |
3712 KB |
Output is correct |
28 |
Correct |
173 ms |
3832 KB |
Output is correct |
29 |
Correct |
294 ms |
3832 KB |
Output is correct |
30 |
Correct |
369 ms |
3796 KB |
Output is correct |