Submission #990334

#TimeUsernameProblemLanguageResultExecution timeMemory
990334vqpahmadSkyscraper (JOI16_skyscraper)C++14
0 / 100
21 ms157788 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...