Submission #202267

#TimeUsernameProblemLanguageResultExecution timeMemory
202267SegtreeSkyscraper (JOI16_skyscraper)C++14
15 / 100
1384 ms198008 KiB
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<set> #include<unordered_set> #include<unordered_map> using namespace std; typedef long long ll; #define chmax(a,b) a=max(a,b) #define chmin(a,b) a=min(a,b) #define all(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<n;i++) #define mod 1000000007 #define mad(a,b) a=(a+b)%mod ll n,L,a[14]; ll dp[(1<<14)][14][110]; int main(){ cin>>n>>L; if(n>14)return 0; rep(i,n)cin>>a[i]; rep(s,(1<<n))rep(x,n)rep(l,110)dp[s][x][l]=0; rep(i,n)dp[(1<<i)][i][0]=1; rep(s,(1<<n))rep(x,n)rep(l,110){ rep(y,n)if(!(s&(1<<y))){ if(l+abs(a[x]-a[y])<110){ mad(dp[s+(1<<y)][y][l+abs(a[x]-a[y])],dp[s][x][l]); } } } ll ans=0; rep(x,n)rep(l,L+1)mad(ans,dp[(1<<n)-1][x][l]); cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...