Submission #798950

#TimeUsernameProblemLanguageResultExecution timeMemory
798950vjudge1Candies (JOI18_candies)C++17
8 / 100
405 ms41560 KiB
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

ll dp[1111][2222], arr[2222];

main() {
#ifdef Home
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // Home
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    for(int i = 1; i <= n; ++ i) {
        cin >> arr[i];
    }
    for(int j = 1; j <= (n + 1) / 2; ++ j) {
        for(int i = 2 * j - 1; i <= n; ++ i) {
            dp[j][i] = max(dp[j][i - 1], (i > 1 ? dp[j - 1][i - 2] : 0) + arr[i]);
        }
        cout << dp[j][n] << '\n';
    }
}

Compilation message (stderr)

candies.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...