Submission #601714

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
6017142022-07-22 09:21:501binSkyscraper (JOI16_skyscraper)C++14
100 / 100
198 ms121004 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];
if(n == 1){
cout << "1"; return 0;
}
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) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...