제출 #45049

#제출 시각아이디문제언어결과실행 시간메모리
45049RayaBurong25_1Candies (JOI18_candies)C++17
8 / 100
34 ms16676 KiB
#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]);
    }
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...