This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define ll long long
#define F first
#define S second
#define mp make_pair
#define ii pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll MOD=1e9+7;
int n,l,x;
const int tam=10005;
ll dp[tam][50];
ll f(int pos , int cant){
if(cant==0)return 1;
if(pos>l)return 0;
if(dp[pos][cant]!=-1)return dp[pos][cant];
dp[pos][cant]=f(pos+1,cant)+f(pos+x,cant-1);
dp[pos][cant]%=MOD;
return dp[pos][cant];
}
ll fact(int n){
ll res=1;
for(int i=1;i<=n;i++){
res*=i;
res%=MOD;
}
return res;
}
int main(){
memset(dp,-1,sizeof(dp));
cin>>n>>l;
for(int i=0;i<n;i++){
cin>>x;
}
cout<<f(1,n)*fact(n)%MOD<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |