# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860952 | 2023-10-14T22:08:23 Z | blackslex | Skyscraper (JOI16_skyscraper) | C++17 | 104 ms | 98384 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 105, L = 1005, M = 1e9 + 7; ll n, d, a[N], dp[N][N][L][3]; int main() { scanf("%lld %lld", &n, &d); for (int i = 1; i <= n; i++) scanf("%lld", &a[i]); sort(a + 1, a + n + 1); 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 l = 0; l <= d; l++) { for (int k = 0; k < 3; k++) { int cur = l + (a[i + 1] - a[i]) * (j * 2LL - k); if (cur > d) continue; dp[i + 1][j - 1][cur][k] += (j - 1LL) * dp[i][j][l][k]; dp[i + 1][j - 1][cur][k] %= M; // add, merge dp[i + 1][j][cur][k] += (j * 2LL - k) * dp[i][j][l][k]; dp[i + 1][j][cur][k] %= M; // add, merge one ending point dp[i + 1][j + 1][cur][k] += (j + 1LL - k) * dp[i][j][l][k]; dp[i + 1][j + 1][cur][k] %= M; // add, no merge if (k == 2) continue; dp[i + 1][j][cur][k + 1] += (2LL - k) * dp[i][j][l][k]; dp[i + 1][j][cur][k + 1] %= M; // add, fix, merge dp[i + 1][j + 1][cur][k + 1] = (2LL - k) * dp[i][j][l][k]; dp[i + 1][j + 1][cur][k + 1] %= M; // add, fix, no merge } } } } for (int i = 1; i <= d; i++) dp[n][1][i][2] += dp[n][1][i - 1][2], dp[n][1][i][2] %= M; printf("%lld", (dp[n][1][d][2] + (n == 1)) % M); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 3164 KB | Output is correct |
6 | Correct | 1 ms | 5212 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2652 KB | Output is correct |
9 | Correct | 1 ms | 5212 KB | Output is correct |
10 | Correct | 1 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Correct | 1 ms | 2908 KB | Output is correct |
3 | Correct | 1 ms | 2908 KB | Output is correct |
4 | Correct | 1 ms | 2908 KB | Output is correct |
5 | Correct | 1 ms | 2908 KB | Output is correct |
6 | Correct | 1 ms | 3164 KB | Output is correct |
7 | Correct | 1 ms | 2908 KB | Output is correct |
8 | Correct | 1 ms | 2908 KB | Output is correct |
9 | Correct | 1 ms | 3164 KB | Output is correct |
10 | Correct | 1 ms | 2908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 3164 KB | Output is correct |
6 | Correct | 1 ms | 5212 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2652 KB | Output is correct |
9 | Correct | 1 ms | 5212 KB | Output is correct |
10 | Correct | 1 ms | 2652 KB | Output is correct |
11 | Correct | 1 ms | 2904 KB | Output is correct |
12 | Correct | 1 ms | 2908 KB | Output is correct |
13 | Correct | 1 ms | 2908 KB | Output is correct |
14 | Correct | 1 ms | 2908 KB | Output is correct |
15 | Correct | 1 ms | 2908 KB | Output is correct |
16 | Correct | 1 ms | 3164 KB | Output is correct |
17 | Correct | 1 ms | 2908 KB | Output is correct |
18 | Correct | 1 ms | 2908 KB | Output is correct |
19 | Correct | 1 ms | 3164 KB | Output is correct |
20 | Correct | 1 ms | 2908 KB | Output is correct |
21 | Correct | 2 ms | 5724 KB | Output is correct |
22 | Correct | 81 ms | 82396 KB | Output is correct |
23 | Correct | 102 ms | 91888 KB | Output is correct |
24 | Correct | 94 ms | 93428 KB | Output is correct |
25 | Correct | 102 ms | 98384 KB | Output is correct |
26 | Correct | 91 ms | 89728 KB | Output is correct |
27 | Correct | 40 ms | 50000 KB | Output is correct |
28 | Correct | 50 ms | 57940 KB | Output is correct |
29 | Correct | 85 ms | 91472 KB | Output is correct |
30 | Correct | 104 ms | 94948 KB | Output is correct |