Submission #917565

#TimeUsernameProblemLanguageResultExecution timeMemory
91756512345678Candies (JOI18_candies)C++17
8 / 100
15 ms32088 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int nx=2e3+5; ll n, a[nx], dp[nx][nx]; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=1; i<=n; i++) cin>>a[i]; for (int i=1; i<=n; i++) for (int j=0; j<=n; j++) dp[i][j]=LLONG_MIN; for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) dp[i][j]=max(dp[i][j-1], dp[i-1][max(0, j-2)]+a[j]); for (int i=1; i<=(n+1)/2; i++) cout<<dp[i][n]<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...