# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
375545 | 2021-03-09T13:59:26 Z | spatarel | Skyscraper (JOI16_skyscraper) | C++17 | 211 ms | 6764 KB |
#include <stdio.h> #include <algorithm> const int MOD = 1000000007; const int MAX_N = 100; const int MAX_L = 1000; long long Count[2][1 + MAX_N + 1][1 + MAX_L][1 + 2 + 1]; void addSelf(long long &a, long long b) { a = (a + b) % MOD; } int main() { int N, L; scanf("%d%d", &N, &L); int A[1 + N]; for (int i = 1; i <= N; i++) { scanf("%d", &A[i]); } A[0] = A[1]; std::sort(A + 1, A + N + 1); Count[0][0][0][0] = 1; int I = 0; int newI = 1; for (int i = 0; i + 1 <= N; i++) { for (int d = 0; d <= N; d++) { for (int l = 0; l <= L; l++) { for (int e = 0; e <= 2; e++) { Count[newI][d][l][e] = 0; } } } for (int d = 0; d <= N; d++) { for (int l = 0; l <= L; l++) { for (int e = 0; e <= 2; e++) { int newL = l+(2*d-e)*(A[i+1]-A[i]); if (0 <= newL && newL <= L) { addSelf(Count[newI][d + 1][newL][e] , (d+1-e) * Count[I][d][l][e]); // valley if (0 <= d - 1) { addSelf(Count[newI][d - 1][newL][e] , (d-1) * Count[I][d][l][e]); // peak } addSelf(Count[newI][d + 0][newL][e] , (2*d-e) * Count[I][d][l][e]); // edge addSelf(Count[newI][d + 0][newL][e + 1], (2-e) * Count[I][d][l][e]); // edge ending addSelf(Count[newI][d + 1][newL][e + 1], (2-e) * Count[I][d][l][e]); // valley ending } } } } std::swap(I, newI); } long long answer = 0; for (int l = 0; l <= L; l++) { addSelf(answer, Count[N % 2][1][l][2]); } if (N == 1) { answer = 1; } printf("%lld\n", answer); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 2 ms | 876 KB | Output is correct |
6 | Correct | 2 ms | 876 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 876 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 1 ms | 488 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 2 ms | 876 KB | Output is correct |
6 | Correct | 2 ms | 876 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 876 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 488 KB | Output is correct |
17 | Correct | 1 ms | 492 KB | Output is correct |
18 | Correct | 1 ms | 492 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Correct | 1 ms | 492 KB | Output is correct |
21 | Correct | 2 ms | 768 KB | Output is correct |
22 | Correct | 184 ms | 5228 KB | Output is correct |
23 | Correct | 211 ms | 6636 KB | Output is correct |
24 | Correct | 180 ms | 5868 KB | Output is correct |
25 | Correct | 211 ms | 6764 KB | Output is correct |
26 | Correct | 185 ms | 6636 KB | Output is correct |
27 | Correct | 64 ms | 2668 KB | Output is correct |
28 | Correct | 95 ms | 3052 KB | Output is correct |
29 | Correct | 167 ms | 4716 KB | Output is correct |
30 | Correct | 211 ms | 6636 KB | Output is correct |