Submission #45040

# Submission time Handle Problem Language Result Execution time Memory
45040 2018-04-11T05:00:59 Z RayaBurong25_1 Candies (JOI18_candies) C++17
0 / 100
54 ms 23928 KB
#include <stdio.h>
long long A[2005];
long long DP[2005][2005];
long long Ans[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]);
            Ans[i] = max(Ans[i], DP[j][i]);
        }
        // printf("\n");
        printf("%lld\n", Ans[i]);
    }
}

Compilation message

candies.cpp: In function 'int main()':
candies.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
candies.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &A[i]);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 23928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 23928 KB Output isn't correct
2 Halted 0 ms 0 KB -