# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172301 | arnold518 | Candies (JOI18_candies) | C++14 | 35 ms | 31996 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2000;
const ll INF = 1e16;
int N, A[MAXN+10];
ll dp[MAXN+10][MAXN+10];
int main()
{
int i, j;
scanf("%d", &N);
for(i=1; i<=N; i++) scanf("%d", &A[i]);
for(i=0; i<=N; i++) for(j=0; j<=N; j++) dp[i][j]=-INF;
dp[1][1]=A[1];
for(i=0; i<=N; i++) dp[i][0]=0;
for(i=2; i<=N; i++)
{
for(j=1; j<=(N+1)/2; j++)
{
dp[i][j]=max(dp[i-1][j], dp[i-2][j-1]+A[i]);
}
}
for(i=1; i<=(N+1)/2; i++) printf("%lld\n", dp[N][i]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |