Submission #138058

#TimeUsernameProblemLanguageResultExecution timeMemory
138058ioilolcomCandies (JOI18_candies)C++14
8 / 100
36 ms16940 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" typedef long long int ll; const int N=2e3+5; ll dp[N][N]; ll a[N]; int main() { ios_base:: sync_with_stdio(false); cin.tie(0); int n; cin>>n; for(int i=1; i<=n; i++) { cin>>a[i]; dp[i][1]=max(dp[i-1][1],a[i]); } for(int k=2; k<=(n+1/2); k++) { for(int i=2*k-1; i<=n; i++) { dp[i][k]=max(dp[i-1][k],dp[i-2][k-1]+a[i]); } } for(int i=1; i<=(n+1)/2; i++) { cout<<dp[n][i]<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...