Submission #782956

#TimeUsernameProblemLanguageResultExecution timeMemory
7829561075508020060209tcCandies (JOI18_candies)C++14
8 / 100
652 ms408692 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int n; int ar[500005]; int dp[5010][5010]; signed main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>ar[i]; } for(int i=0;i<=n;i++){ for(int j=1;j<=n;j++){ dp[i][j]=-1e16; } } dp[0][0]=0; dp[1][0]=0; dp[1][1]=ar[1]; for(int i=2;i<=n;i++){ for(int j=1;j<=i;j++){ dp[i][j]=max(dp[i-1][j],dp[i-2][j-1]+ar[i]); } } for(int i=1;i<=(n+1)/2;i++){ cout<<dp[n][i]<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...