# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037083 | 2024-07-28T03:24:08 Z | LucaDantas | Candies (JOI18_candies) | C++17 | 6 ms | 31608 KB |
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 2010, maxk = 2010; int a[maxn]; long long dp[maxn][maxk]; int main() { int n; scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", a+i); for(int i = 1; i <= n; i++) for(int j = 1; j <= (i+1)/2; j++) dp[i][j] = max({dp[i-1][j], (i >= 2 ? dp[i-2][j-1] : 0) + a[i]}); for(int j = 1; j <= (n+1)/2; j++) printf("%lld\n", dp[n][j]); // puts("VALORES"); // for(int i = 1; i <= n; i++) { // for(int j = 1; j <= (i+1)/2; j++) // printf("%d ", dp[i][j]); // printf("\n"); // } // puts("DELTAS"); // for(int i = 1; i <= n; i++) { // printf("(%d) ", a[i]); // for(int j = 1; j <= (i+1)/2; j++) // printf("%d ", dp[i][j] - dp[i][j-1]); // printf("\n"); // } // for(int i = 1; i <= n; i++) // for(int j = 2; j <= (i+1)/2; j++) // assert(dp[i][j] - dp[i][j-1] <= dp[i][j-1] - dp[i][j-2]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 31580 KB | Output is correct |
2 | Correct | 5 ms | 31580 KB | Output is correct |
3 | Correct | 4 ms | 31528 KB | Output is correct |
4 | Correct | 4 ms | 31580 KB | Output is correct |
5 | Correct | 5 ms | 31580 KB | Output is correct |
6 | Correct | 4 ms | 31580 KB | Output is correct |
7 | Correct | 4 ms | 31608 KB | Output is correct |
8 | Correct | 4 ms | 31580 KB | Output is correct |
9 | Correct | 5 ms | 31580 KB | Output is correct |
10 | Correct | 4 ms | 31444 KB | Output is correct |
11 | Correct | 5 ms | 31580 KB | Output is correct |
12 | Correct | 5 ms | 31512 KB | Output is correct |
13 | Correct | 4 ms | 31496 KB | Output is correct |
14 | Correct | 4 ms | 31580 KB | Output is correct |
15 | Correct | 4 ms | 31580 KB | Output is correct |
16 | Correct | 4 ms | 31540 KB | Output is correct |
17 | Correct | 6 ms | 31580 KB | Output is correct |
18 | Correct | 4 ms | 31580 KB | Output is correct |
19 | Correct | 5 ms | 31580 KB | Output is correct |
20 | Correct | 5 ms | 31444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 31580 KB | Output is correct |
2 | Correct | 5 ms | 31580 KB | Output is correct |
3 | Correct | 4 ms | 31528 KB | Output is correct |
4 | Correct | 4 ms | 31580 KB | Output is correct |
5 | Correct | 5 ms | 31580 KB | Output is correct |
6 | Correct | 4 ms | 31580 KB | Output is correct |
7 | Correct | 4 ms | 31608 KB | Output is correct |
8 | Correct | 4 ms | 31580 KB | Output is correct |
9 | Correct | 5 ms | 31580 KB | Output is correct |
10 | Correct | 4 ms | 31444 KB | Output is correct |
11 | Correct | 5 ms | 31580 KB | Output is correct |
12 | Correct | 5 ms | 31512 KB | Output is correct |
13 | Correct | 4 ms | 31496 KB | Output is correct |
14 | Correct | 4 ms | 31580 KB | Output is correct |
15 | Correct | 4 ms | 31580 KB | Output is correct |
16 | Correct | 4 ms | 31540 KB | Output is correct |
17 | Correct | 6 ms | 31580 KB | Output is correct |
18 | Correct | 4 ms | 31580 KB | Output is correct |
19 | Correct | 5 ms | 31580 KB | Output is correct |
20 | Correct | 5 ms | 31444 KB | Output is correct |
21 | Runtime error | 2 ms | 604 KB | Execution killed with signal 11 |
22 | Halted | 0 ms | 0 KB | - |