제출 #1037081

#제출 시각아이디문제언어결과실행 시간메모리
1037081LucaDantasCandies (JOI18_candies)C++17
0 / 100
1 ms2652 KiB
#include <bits/stdc++.h>
using namespace std;

constexpr int maxn = 2e5+10, maxk = 100;

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]);
}

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

candies.cpp: In function 'int main()':
candies.cpp:10:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     int n; scanf("%d", &n);
      |            ~~~~~^~~~~~~~~~
candies.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d", a+i);
      |         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...