# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62605 | gusfring | Candies (JOI18_candies) | C++14 | 23 ms | 12512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 5;
typedef long long ll;
int N, A[MAXN];
long long dp[MAXN][MAXN];
int main(){
scanf("%d", &N);
for(int i=1; i<=N; ++i){
scanf("%d", &A[i]);
dp[1][i] = max(dp[1][i - 1], 1LL * A[i]);
}
for(int k=2; k<=(N+1)/2; ++k)
for(int i=2*k-1; i<=N; ++i) dp[k][i] = max(dp[k - 1][i - 2] + A[i], dp[k][i - 1]);
for(int k=1; k<=(N+1)/2; ++k) printf("%lld ", dp[k][N]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |