Submission #936201

#TimeUsernameProblemLanguageResultExecution timeMemory
936201AdamGSSkyscraper (JOI16_skyscraper)C++17
15 / 100
201 ms190036 KiB
#include<bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const ll MOD=1e9+7; ll dp[1<<14][14][107], T[14]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, l; cin >> n >> l; rep(i, n) cin >> T[i]; rep(i, n) dp[1<<i][i][0]=1; rep(i, 1<<n) rep(j, n) if(i&(1<<j)) { rep(k, n) if(j!=k && (i&(1<<k))) { for(int a=abs(T[j]-T[k]); a<=l; ++a) { dp[i][j][a]=(dp[i][j][a]+dp[i-(1<<j)][k][a-abs(T[j]-T[k])])%MOD; } } } ll ans=0; rep(i, n) rep(j, l+1) ans=(ans+dp[(1<<n)-1][i][j])%MOD; cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...