Submission #45049

# Submission time Handle Problem Language Result Execution time Memory
45049 2018-04-11T05:15:01 Z RayaBurong25_1 Candies (JOI18_candies) C++17
8 / 100
34 ms 16676 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 = 2*(i - 1); 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

candies.cpp: In function 'int main()':
candies.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
candies.cpp:15: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 Correct 32 ms 16120 KB Output is correct
2 Correct 25 ms 16356 KB Output is correct
3 Correct 28 ms 16356 KB Output is correct
4 Correct 33 ms 16368 KB Output is correct
5 Correct 26 ms 16432 KB Output is correct
6 Correct 34 ms 16452 KB Output is correct
7 Correct 29 ms 16488 KB Output is correct
8 Correct 32 ms 16488 KB Output is correct
9 Correct 31 ms 16524 KB Output is correct
10 Correct 32 ms 16524 KB Output is correct
11 Correct 32 ms 16524 KB Output is correct
12 Correct 27 ms 16616 KB Output is correct
13 Correct 25 ms 16616 KB Output is correct
14 Correct 33 ms 16616 KB Output is correct
15 Correct 34 ms 16616 KB Output is correct
16 Correct 25 ms 16628 KB Output is correct
17 Correct 33 ms 16628 KB Output is correct
18 Correct 27 ms 16628 KB Output is correct
19 Correct 34 ms 16656 KB Output is correct
20 Correct 23 ms 16676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 16120 KB Output is correct
2 Correct 25 ms 16356 KB Output is correct
3 Correct 28 ms 16356 KB Output is correct
4 Correct 33 ms 16368 KB Output is correct
5 Correct 26 ms 16432 KB Output is correct
6 Correct 34 ms 16452 KB Output is correct
7 Correct 29 ms 16488 KB Output is correct
8 Correct 32 ms 16488 KB Output is correct
9 Correct 31 ms 16524 KB Output is correct
10 Correct 32 ms 16524 KB Output is correct
11 Correct 32 ms 16524 KB Output is correct
12 Correct 27 ms 16616 KB Output is correct
13 Correct 25 ms 16616 KB Output is correct
14 Correct 33 ms 16616 KB Output is correct
15 Correct 34 ms 16616 KB Output is correct
16 Correct 25 ms 16628 KB Output is correct
17 Correct 33 ms 16628 KB Output is correct
18 Correct 27 ms 16628 KB Output is correct
19 Correct 34 ms 16656 KB Output is correct
20 Correct 23 ms 16676 KB Output is correct
21 Execution timed out 2 ms 16676 KB Time limit exceeded (wall clock)
22 Halted 0 ms 0 KB -