# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
615591 |
2022-07-31T10:56:03 Z |
bebra |
Candies (JOI18_candies) |
C++17 |
|
11 ms |
27220 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)2000;
long long dp[MAX_N][MAX_N / 2][2];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (auto& x : a) cin >> x;
dp[0][0][0] = 0;
dp[0][1][1] = a[0];
for (int i = 1; i < n; ++i) {
for (int j = 0; j <= min(i, (n + 1) / 2); ++j) {
dp[i][j][0] = max(dp[i - 1][j][0], dp[i - 1][j][1]);
if (j >= 1) {
dp[i][j][1] = dp[i - 1][j - 1][0] + a[i];
}
}
}
for (int j = 1; j <= (n + 1) / 2; ++j) {
cout << max(dp[n - 1][j][0], dp[n - 1][j][1]) << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
27220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
27220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |