#include<bits/stdc++.h>
using namespace std;
//int dp0[101][51],dp1[105][51],dp2[101][51];
long long cnt[1<<14][14][1001];
int vl[14],mod=1e9+7;
int main(){
int n,l;
cin>>n>>l;
for(int i=0;i<n;i++)
cin>>vl[i],cnt[1<<i][i][0]=1;
for(int i=1;i<1<<n;i++)
for(int j=0;j<n;j++)if(i&1<<j) {
for(int k=0;k<=l;k++)
cnt[i][j][k]%=mod;
for(int k=0;k<n;k++)if(~i&1<<k){
int cst=abs(vl[j]-vl[k]);
for(int v=0;v<=l-cst;v++)
cnt[i^1<<k][k][v+cst]+=cnt[i][j][v];
}
}
long long ans=0;
for(int i=0;i<=l;i++)
for(int x=0;x<n;x++)
ans+=cnt[(1<<n)-1][x][i];
cout<<ans%mod;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
1372 KB |
Output is correct |
5 |
Correct |
7 ms |
10332 KB |
Output is correct |
6 |
Correct |
6 ms |
10076 KB |
Output is correct |
7 |
Correct |
2 ms |
5724 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
7 ms |
10332 KB |
Output is correct |
10 |
Correct |
3 ms |
5468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
111444 KB |
Output is correct |
2 |
Runtime error |
238 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
1372 KB |
Output is correct |
5 |
Correct |
7 ms |
10332 KB |
Output is correct |
6 |
Correct |
6 ms |
10076 KB |
Output is correct |
7 |
Correct |
2 ms |
5724 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
7 ms |
10332 KB |
Output is correct |
10 |
Correct |
3 ms |
5468 KB |
Output is correct |
11 |
Correct |
51 ms |
111444 KB |
Output is correct |
12 |
Runtime error |
238 ms |
524288 KB |
Execution killed with signal 9 |
13 |
Halted |
0 ms |
0 KB |
- |