# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442844 | 2021-07-09T08:50:02 Z | parsabahrami | Skyscraper (JOI16_skyscraper) | C++17 | 1 ms | 844 KB |
/* I do it for the glory */ #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 1e2 + 10, MOD = 1e9 + 7; int dp[N][N][10 * N][3], A[N], n, L; void add(int &x, int y) { x += y; if (x >= MOD) x -= MOD; } int main() { scanf("%d%d", &n, &L); dp[0][0][0][0] = 1; for (int i = 1; i <= n; i++) scanf("%d", &A[i]); sort(A + 1, A + n + 1); for (int i = 1; i <= n; i++) { for (int j = 0; j <= i; j++) { for (int k = 0; k <= L; k++) { for (int t = 0; t <= min(j, 2); t++) { int nk = k + (A[i] - A[i - 1]) * (2 * j - t); if (nk > L) continue; if (t < 2) add(dp[i][j + 1][nk][t + 1], dp[i - 1][j][k][t] * (2ll - t) % MOD); if (t < 2 && j) add(dp[i][j][nk][t + 1], dp[i - 1][j][k][t] * (2ll - t) % MOD); if (j > 1) add(dp[i][j - 1][nk][t], 1ll * dp[i - 1][j][k][t] * (j - 1) % MOD); if (j) add(dp[i][j][nk][t], dp[i - 1][j][k][t] * 1ll * (2 * j - t) % MOD); add(dp[i][j + 1][nk][t], 1l * dp[i - 1][j][k][t] * (j + 1 - t) % MOD); } } } } int ret = 0; for (int i = 0; i <= L; i++) add(ret, dp[n][1][i][2]); printf("%d\n", ret); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 716 KB | Output is correct |
2 | Correct | 1 ms | 688 KB | Output is correct |
3 | Correct | 1 ms | 844 KB | Output is correct |
4 | Correct | 1 ms | 716 KB | Output is correct |
5 | Correct | 1 ms | 716 KB | Output is correct |
6 | Correct | 1 ms | 844 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 844 KB | Output is correct |
9 | Correct | 1 ms | 844 KB | Output is correct |
10 | Correct | 1 ms | 684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |