# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
912501 | fanwen | Skyscraper (JOI16_skyscraper) | C++17 | 34 ms | 28844 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int Mod = 1e9 + 7;
int n, L, a[101];
long long dp[101][101][1005][3];
signed main() {
cin >> n >> L;
for (int i = 1; i <= n; ++i) cin >> a[i];
sort(a + 1, a + n + 1);
if(n == 1) {
cout << 1;
return 0;
}
dp[1][1][0][0] = 1;
dp[1][1][0][1] = 2;
for (int i = 1; i < n; ++i) {
for (int j = 1; j <= i; ++j) {
for (int k = 0; k <= L; ++k) {
for (int e = 0; e < 3; ++e) {
if(dp[i][j][k][e] == 0) continue;
int new_cost = k + (a[i + 1] - a[i]) * (2 * j - e);
if(new_cost > L) continue;
(dp[i + 1][j + 1][new_cost][e] += dp[i][j][k][e] * (j + 1 - e)) %= Mod;
(dp[i + 1][j][new_cost][e] += dp[i][j][k][e] * (2 * j - e)) %= Mod;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |