# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47828 | mirbek01 | Candies (JOI18_candies) | C++17 | 19 ms | 12448 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 N = 2e3 + 2;
int n, a[N];
long long dp[N][N];
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; i ++){
cin >> a[i];
dp[1][i] = max(dp[1][i - 1], 1ll* a[i]);
}
for(int i = 2; i <= (n + 1) / 2; i ++){
for(int j = i * 2 - 1; j <= n; j ++){
dp[i][j] = max(dp[i - 1][j - 2] + a[j], dp[i][j - 1]);
}
}
for(int i = 1; i <= (n + 1) / 2; i ++){
cout << dp[i][n] << endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |