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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mod 998244353
// #define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>;
int n,k;
int arr[210];
int dp[200][201][1001];
int slv(int i,int cur,int tot){
if(tot>k)return 0;
if(i==n){
if(cur)return 0;
else return 1;
}
if(dp[i][cur][tot]!=-1)return dp[i][cur][tot];
if(!cur)return dp[i][cur][tot]=(slv(i+1,1,tot)+slv(i+1,0,tot))%1000000007;
long long ans=slv(i+1,cur+1,tot+(arr[i]-arr[i-1])*cur);
ans+=(slv(i+1,cur,tot+(arr[i]-arr[i-1])*cur)*(long long)(cur+1))%1000000007;
ans+=(slv(i+1,cur-1,tot+(arr[i]-arr[i-1])*cur)*(long long)cur)%1000000007;
return dp[i][cur][tot]=(ans%1000000007);
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
memset(dp,-1,sizeof dp);
cin>>n>>k;
for(int i=0;i<n;i++)cin>>arr[i];
sort(arr,arr+n);
cout<<slv(0,0,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... |