Submission #861123

#TimeUsernameProblemLanguageResultExecution timeMemory
861123eitanelbCandies (JOI18_candies)C++14
8 / 100
201 ms524288 KiB
#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++){ ll 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...