#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9 + 7;
int a[101], n, L;
ll dp[101][101][3][1001];
ll f(int i, int g, int end, int sum) {
sum += (a[i] - a[i - 1]) * (2 * g + end);
if(g < 0 || end > 2 || sum > L) return 0;
if(i == n) return g == 0 && end;
ll &ret = dp[i][g][end][sum];
if(~ret) return ret;
ret = (g + 1) * f(i + 1, g + 1, end, sum);
ret += (2 * g + end) * f(i + 1, g, end, sum);
ret += (g + end - 1) * f(i + 1, g - 1, end, sum);
ret += (2 - end) * f(i + 1, g, end + 1, sum);
ret += (2 - end) * f(i + 1, g - 1, end + 1, sum);
ret %= mod;
return ret;
}
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
freopen("in", "r", stdin);
#endif
scanf("%d %d", &n, &L);
for(int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
} sort(a + 1, a + n + 1);
memset(dp, -1, sizeof dp);
printf("%lld\n", n == 1 ? 1 : f(1, 0, 0, 0));
}
Compilation message
skyscraper.cpp: In function 'int main(int, const char**)':
skyscraper.cpp:30:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &L);
^
skyscraper.cpp:32:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
240080 KB |
Output is correct |
2 |
Correct |
175 ms |
240152 KB |
Output is correct |
3 |
Correct |
177 ms |
240252 KB |
Output is correct |
4 |
Correct |
175 ms |
240468 KB |
Output is correct |
5 |
Correct |
176 ms |
240468 KB |
Output is correct |
6 |
Correct |
176 ms |
240468 KB |
Output is correct |
7 |
Correct |
175 ms |
240468 KB |
Output is correct |
8 |
Correct |
174 ms |
240468 KB |
Output is correct |
9 |
Correct |
175 ms |
240496 KB |
Output is correct |
10 |
Correct |
177 ms |
240496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
177 ms |
240524 KB |
Output is correct |
2 |
Correct |
176 ms |
240524 KB |
Output is correct |
3 |
Correct |
185 ms |
240524 KB |
Output is correct |
4 |
Correct |
178 ms |
240524 KB |
Output is correct |
5 |
Correct |
189 ms |
240604 KB |
Output is correct |
6 |
Correct |
177 ms |
240624 KB |
Output is correct |
7 |
Correct |
181 ms |
240624 KB |
Output is correct |
8 |
Correct |
194 ms |
240624 KB |
Output is correct |
9 |
Correct |
179 ms |
240624 KB |
Output is correct |
10 |
Correct |
186 ms |
240624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
240080 KB |
Output is correct |
2 |
Correct |
175 ms |
240152 KB |
Output is correct |
3 |
Correct |
177 ms |
240252 KB |
Output is correct |
4 |
Correct |
175 ms |
240468 KB |
Output is correct |
5 |
Correct |
176 ms |
240468 KB |
Output is correct |
6 |
Correct |
176 ms |
240468 KB |
Output is correct |
7 |
Correct |
175 ms |
240468 KB |
Output is correct |
8 |
Correct |
174 ms |
240468 KB |
Output is correct |
9 |
Correct |
175 ms |
240496 KB |
Output is correct |
10 |
Correct |
177 ms |
240496 KB |
Output is correct |
11 |
Correct |
177 ms |
240524 KB |
Output is correct |
12 |
Correct |
176 ms |
240524 KB |
Output is correct |
13 |
Correct |
185 ms |
240524 KB |
Output is correct |
14 |
Correct |
178 ms |
240524 KB |
Output is correct |
15 |
Correct |
189 ms |
240604 KB |
Output is correct |
16 |
Correct |
177 ms |
240624 KB |
Output is correct |
17 |
Correct |
181 ms |
240624 KB |
Output is correct |
18 |
Correct |
194 ms |
240624 KB |
Output is correct |
19 |
Correct |
179 ms |
240624 KB |
Output is correct |
20 |
Correct |
186 ms |
240624 KB |
Output is correct |
21 |
Correct |
193 ms |
240624 KB |
Output is correct |
22 |
Correct |
296 ms |
240624 KB |
Output is correct |
23 |
Correct |
287 ms |
240624 KB |
Output is correct |
24 |
Correct |
261 ms |
240624 KB |
Output is correct |
25 |
Correct |
297 ms |
240624 KB |
Output is correct |
26 |
Correct |
258 ms |
240624 KB |
Output is correct |
27 |
Correct |
206 ms |
240624 KB |
Output is correct |
28 |
Correct |
216 ms |
240624 KB |
Output is correct |
29 |
Correct |
267 ms |
240776 KB |
Output is correct |
30 |
Correct |
294 ms |
240776 KB |
Output is correct |