Submission #475039

#TimeUsernameProblemLanguageResultExecution timeMemory
475039SirCovidThe19thSkyscraper (JOI16_skyscraper)C++17
15 / 100
5 ms4044 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, x, y) for (int i = x; i < y; i++) int N, L, A[105], md = 1e9 + 7; long long dp[105][105][1005][5], ans; int main(){ cin >> N >> L; FOR(i, 1, N + 1) cin >> A[i]; sort(A + 1, A + N + 1); dp[0][0][0][0] = 1; FOR(i, 0, N + 1) FOR(j, 0, N + 1) FOR(l, 0, L + 1) FOR(m, 0, 3){ int dif = (A[i + 1] - A[i]) * (2 * j - m); long long &DP = dp[i][j][l][m]; DP %= md; if (l + dif > L) continue; if (j) dp[i + 1][j - 1][l + dif][m] += DP * (j - 1); //merge dp[i + 1][j + 1][l + dif][m] += DP * (j + 1 - m); //new dp[i + 1][j][l + dif][m] += DP * (2 * j - m); //append dp[i + 1][j][l + dif][m + 1] += DP * (2 - m); //append end dp[i + 1][j + 1][l + dif][m + 1] += DP * (2 - m); //create end if (i == N and j == 1 and m == 2) ans += DP, ans %= md; } cout<<(N == 1 ? 1 : ans)<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...