# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45039 | 2018-04-11T04:59:09 Z | RayaBurong25_1 | Candies (JOI18_candies) | C++17 | 60 ms | 23928 KB |
#include <stdio.h> long long A[2005]; long long DP[2005][2005]; long long max(long long a, long long b) { return (a > b)?a:b; } int main() { //just a proof of concept int N; scanf("%d", &N); int i, j; for (i = 0; i < N; i++) scanf("%lld", &A[i]); for (i = 1; i <= (N + 1)/2; i++) { for (j = 0; j < N; j++) { if (i == 1) DP[j][i] = A[j]; if (j > 0) DP[j][i] = max(DP[j][i], DP[j - 1][i]); if (j > 1) DP[j][i] = max(DP[j][i], DP[j - 2][i - 1] + A[j]); // printf("%lld ", DP[j][i]); } // printf("\n"); printf("%lld\n", DP[N - 1][i]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 60 ms | 23928 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 60 ms | 23928 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |