Submission #1215908

#TimeUsernameProblemLanguageResultExecution timeMemory
1215908omarrrrSkyscraper (JOI16_skyscraper)C++20
0 / 100
170 ms212056 KiB
#include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back using namespace std; const ll N=1e6,mod=1e9 +7; ll a,b,c,d,n,l; ll t[N]; ll dp[(1<<14)][15][110]; int main(){ ios_base::sync_with_stdio(0),cin.tie(0); ll T=1; // cin>>T; while(T--){ cin>>n>>l; for(ll i=0;i<n;i++){ cin>>t[i]; } memset(dp,0,sizeof(dp)); for(ll i=0;i<n;i++){ dp[(1<<i)][i][0]=1; } for(ll i=0;i<(1<<n);i++){ for(ll j=0;j<n;j++){ if(i&(1<<j)){ for(ll k=0;k<n;k++){ if(!(i & (1<<k))){ for(ll m=0;m<=l;m++){ if(m+abs(t[j]-t[k])<=l) dp[i+(1<<k)][k][m+abs(t[j]-t[k])]+=dp[i][j][m]; } } } } } } ll res=0; for(ll i=0;i<n;i++){ for(ll j=0;j<=l;j++){ res+=dp[(1<<n)-1][i][j]; } } cout<<res<<"\n"; } return 0; } /* 4 10 3 6 2 9 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...