Submission #861122

# Submission time Handle Problem Language Result Execution time Memory
861122 2023-10-15T11:15:05 Z eitanelb Candies (JOI18_candies) C++14
0 / 100
10 ms 16220 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;
    vector<ll> v(n); for(ll &i : v) cin>>i;
    int k = (n+1)/2;
    vector<vector<ll>> dp(n,vector<ll>(k+1,-1e18));
    dp[0][0]=0;
    dp[0][1]=v[0];
    for(int i=1;i<n;i++){
        dp[i][0]=0;
        for(int j = 1;j <= (i/2 + 1);j++){
            int l = 0;
            if(i>1) l = dp[i-2][j-1];
            dp[i][j] = max(dp[i-1][j], l + v[i]);
        }
    }
    /*for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }*/
    for(int i=1;i<=k;i++) cout<<dp[n-1][i]<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 16220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 16220 KB Output isn't correct
2 Halted 0 ms 0 KB -