#include <bits/stdc++.h>
#define bit(x,i) (1&(x>>(i-1)))
#define on(x,i) (x|(1<<(i-1)))
using namespace std;
const int M=1e9+7;
int n,l,kq;
int a[15];
int f[1<<15][15][200];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>l;
for(int i=1;i<=n;++i) cin>>a[i];
f[0][0][0]=1;
for(int tt=0;tt<(1<<n)-1;++tt) for(int i=0;i<=n;++i) for(int t=0;t<=l;++t) if(f[tt][i][t])
for(int j=1;j<=n;++j) if(!bit(tt,j))
{
int tt2=on(tt,j);
int c=(tt==0 ? 0 : t + abs(a[i]-a[j]));
f[tt2][j][c]=(f[tt2][j][c] + f[tt][i][t])%M;
}
for(int i=1;i<=n;++i) for(int t=0;t<=l;++t) kq=(kq+f[(1<<n)-1][i][t])%M;
cout<<kq;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
508 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
760 KB |
Output is correct |
5 |
Incorrect |
27 ms |
3320 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
44540 KB |
Output is correct |
2 |
Correct |
244 ms |
187152 KB |
Output is correct |
3 |
Correct |
318 ms |
185912 KB |
Output is correct |
4 |
Correct |
225 ms |
187256 KB |
Output is correct |
5 |
Correct |
209 ms |
187144 KB |
Output is correct |
6 |
Correct |
324 ms |
187256 KB |
Output is correct |
7 |
Correct |
200 ms |
185848 KB |
Output is correct |
8 |
Correct |
284 ms |
185768 KB |
Output is correct |
9 |
Correct |
352 ms |
185976 KB |
Output is correct |
10 |
Correct |
222 ms |
186700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
508 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
760 KB |
Output is correct |
5 |
Incorrect |
27 ms |
3320 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |