#include<bits/stdc++.h>
#define int long long
const int N=2e5+1;
int mod=1e9+7;
int fac[N],ifac[N],a[N];
int f[61][61][50001];
int qmi(int x,int y){
int res=1;
while(y>0){
if(y&1)
res=res*x%mod;
x=x*x%mod;
y>>=1;
}
return res;
}
void init(int x){
fac[0]=ifac[0]=1;
for(int i=1;i<=x;i++)
fac[i]=fac[i-1]*i%mod;
ifac[x]=qmi(fac[x],mod-2);
for(int i=x-1;i>=1;i--)
ifac[i]=ifac[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
return (n<m||n<0||m<0)?0:fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
inline void add(int &x,int y){
x+=y,x%=mod;
}
void solve(){
int n,m;
std::cin>>n>>m;
for(int i=0;i<m;i++)
std::cin>>a[i];
std::sort(a,a+m);
f[0][0][0]=1;
for(int i=0;i<m;i++){
for(int j=0;j<=i;j++)
for(int k=0;k<=n;k++){
add(f[i+1][j+1][k+1],f[i][j][k]*(j+1)%mod);
add(f[i+1][j][k+a[i]],f[i][j][k]*j*2%mod);
if(j>0)
add(f[i+1][j-1][k+2*a[i]-1],f[i][j][k]*(j-1)%mod);
}
}
int ans=0;
for(int i=1;i<=n;i++){
ans=(ans+C(n-i+m,m)*f[m][1][i]%mod)%mod;
}
std::cout<<ans<<"\n";
}
signed main(){
std::ios::sync_with_stdio(false),std::cin.tie(NULL),std::cout.tie(NULL);
int t=1;
// std::cin>>t;
init(N-2);
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
27 ms |
14940 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
19 ms |
14168 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
14428 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
27 ms |
14940 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |