#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;
ll dp[1<<14][14][107], T[14];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, l;
cin >> n >> l;
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';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
2396 KB |
Output is correct |
5 |
Incorrect |
4 ms |
3164 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
47188 KB |
Output is correct |
2 |
Correct |
195 ms |
189796 KB |
Output is correct |
3 |
Correct |
161 ms |
189008 KB |
Output is correct |
4 |
Correct |
188 ms |
189940 KB |
Output is correct |
5 |
Correct |
182 ms |
190036 KB |
Output is correct |
6 |
Correct |
201 ms |
189660 KB |
Output is correct |
7 |
Correct |
137 ms |
188576 KB |
Output is correct |
8 |
Correct |
154 ms |
188828 KB |
Output is correct |
9 |
Correct |
188 ms |
189608 KB |
Output is correct |
10 |
Correct |
182 ms |
189500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
2396 KB |
Output is correct |
5 |
Incorrect |
4 ms |
3164 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |