Submission #1037081

# Submission time Handle Problem Language Result Execution time Memory
1037081 2024-07-28T03:23:17 Z LucaDantas Candies (JOI18_candies) C++17
0 / 100
1 ms 2652 KB
#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]);
}

Compilation message

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 time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -