제출 #601696

#제출 시각아이디문제언어결과실행 시간메모리
6016961binSkyscraper (JOI16_skyscraper)C++14
15 / 100
2 ms980 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const ll mod = 1e9 + 7; ll n, mx, dp[105][105][1005][5], h[101]; int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> mx; for(int i = 1; i <= n; i++) cin >> h[i]; sort(h + 1, h + n + 1); dp[0][0][0][0] = 1; h[n + 1] = 10000; for(int i = 1; i <= n; i++) for(int j = 1; j <= i; j++) for(int kk = 0; kk <= mx; kk++) for(int l = 0; l < 3; l++){ int d = (2 * j - l) * (h[i + 1] - h[i]); int k = kk + d; if(k > mx) continue; if(j > l) dp[i][j][k][l] += (j - l) * dp[i - 1][j - 1][kk][l]; dp[i][j][k][l] += (2 * j - l) * dp[i - 1][j][kk][l]; dp[i][j][k][l] += j * dp[i - 1][j + 1][kk][l]; if(l) { dp[i][j][k][l] += (3 - l) * dp[i - 1][j - 1][kk][l - 1]; if(i == 2 && j == 1 && k == 5 && l == 1){ //cout << i << ' ' << j << ' ' << kk << ' ' << l - 1 << ' ' << dp[i][j][kk][l - 1] << '\n'; } dp[i][j][k][l] += (3 - l) * dp[i - 1][j][kk][l - 1]; } dp[i][j][k][l] %= mod; //cout << i << ' ' << j << ' ' << k << ' ' << l << ' ' << dp[i][j][k][l] << '\n'; } ll ans = 0; for(int i = 0; i <= mx; i++) ans += dp[n][1][i][2], ans %= mod; cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...