Submission #883307

#TimeUsernameProblemLanguageResultExecution timeMemory
883307phoenix0423Skyscraper (JOI16_skyscraper)C++17
15 / 100
4 ms33296 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define fastio ios::sync_with_stdio(false), cin.tie(0) // #pragma GCC optimize("Ofast") #define FOR(i, a, b) for(int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 0, n + 1) #define SZ(x) (int)(x).size() #define pb push_back #define pf push_front #define eb emplace_back #define f first #define s second #define lowbit(x) x&-x #define ckmin(a, b) a = min(a, b) #define ckmax(a, b) a = max(a, b) #define int long long const int INF = 1e18; const int maxn = 1000 + 5; const int N = 1e9 + 7; ll dp[105][105][1005][3]; signed main(void){ fastio; int n, L; cin>>n>>L; vector<int> a(n); for(int i = 0; i < n; i++) cin>>a[i]; sort(a.begin(), a.end()); a.pb(a[n - 1]); dp[0][0][0][0] = 1; for(int i = 0; i < n; i++){ for(int j = 0; j <= i; j++){ for(int k = 0; k <= L; k++){ for(int l = 0; l <= 2; l++){ dp[i][j][k][l] %= N; if(k + (2 * j - 2 - l) * (a[i + 1] - a[i]) > L) continue; if(j) dp[i + 1][j][k + (2 * j - l) * (a[i + 1] - a[i])][l] += dp[i][j][k][l] * (2 * j - l); dp[i + 1][j + 1][k + (2 * j + 2 - l) * (a[i + 1] - a[i])][l] += dp[i][j][k][l] * (j + 1 - l); if(j > 1) dp[i + 1][j - 1][k + (2 * j - 2 - l) * (a[i + 1] - a[i])][l] += dp[i][j][k][l] * (j - 1); if(l != 2){ dp[i + 1][j][k + (2 * j - (l + 1)) * (a[i + 1] - a[i])][l + 1] += dp[i][j][k][l] * (2 - l);//.............. dp[i + 1][j + 1][k + (2 * j + 2 - (l + 1)) * (a[i + 1] - a[i])][l + 1] += dp[i][j][k][l] * (2 - l); } } } } } ll ans = 0; for(int i = 0; i <= L; i++) (ans += dp[n - 1][2][i][2]) %= N; for(int i = 0; i <= L; i++) (ans += dp[n - 1][1][i][1]) %= N; // for(int i = 0; i <= L; i++) (ans += dp[n][1][i][2]) %= N; cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...