#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll MOD=1e9+7;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, l;
cin >> n >> l;
ll dp[1<<n][n][l+1], T[n];
rep(i, 1<<n) rep(j, n) rep(k, l+1) dp[i][j][k]=0;
rep(i, n) cin >> T[i];
rep(i, n) dp[1<<i][i][0]=1;
rep(i, 1<<n) rep(j, n) if(i&(1<<j)) {
rep(k, n) if(j!=k && (i&(1<<k))) {
for(int a=abs(T[j]-T[k]); a<=l; ++a) {
dp[i][j][a]=(dp[i][j][a]+dp[i-(1<<j)][k][a-abs(T[j]-T[k])])%MOD;
}
}
}
ll ans=0;
rep(i, n) rep(j, l+1) ans=(ans+dp[(1<<n)-1][i][j])%MOD;
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
12 ms |
15492 KB |
Output is correct |
6 |
Correct |
10 ms |
13916 KB |
Output is correct |
7 |
Correct |
2 ms |
2836 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
11 ms |
14940 KB |
Output is correct |
10 |
Correct |
2 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
25172 KB |
Output is correct |
2 |
Correct |
218 ms |
174420 KB |
Output is correct |
3 |
Correct |
115 ms |
82988 KB |
Output is correct |
4 |
Correct |
229 ms |
176180 KB |
Output is correct |
5 |
Correct |
216 ms |
178308 KB |
Output is correct |
6 |
Correct |
221 ms |
167408 KB |
Output is correct |
7 |
Correct |
69 ms |
54252 KB |
Output is correct |
8 |
Correct |
114 ms |
79440 KB |
Output is correct |
9 |
Correct |
181 ms |
131496 KB |
Output is correct |
10 |
Correct |
212 ms |
151040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
12 ms |
15492 KB |
Output is correct |
6 |
Correct |
10 ms |
13916 KB |
Output is correct |
7 |
Correct |
2 ms |
2836 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
11 ms |
14940 KB |
Output is correct |
10 |
Correct |
2 ms |
2396 KB |
Output is correct |
11 |
Correct |
39 ms |
25172 KB |
Output is correct |
12 |
Correct |
218 ms |
174420 KB |
Output is correct |
13 |
Correct |
115 ms |
82988 KB |
Output is correct |
14 |
Correct |
229 ms |
176180 KB |
Output is correct |
15 |
Correct |
216 ms |
178308 KB |
Output is correct |
16 |
Correct |
221 ms |
167408 KB |
Output is correct |
17 |
Correct |
69 ms |
54252 KB |
Output is correct |
18 |
Correct |
114 ms |
79440 KB |
Output is correct |
19 |
Correct |
181 ms |
131496 KB |
Output is correct |
20 |
Correct |
212 ms |
151040 KB |
Output is correct |
21 |
Runtime error |
5 ms |
7000 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |