Submission #486581

#TimeUsernameProblemLanguageResultExecution timeMemory
486581ez_ioiCandies (JOI18_candies)C++17
8 / 100
15 ms23116 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mxN = 2e3 + 5, mod = 1e9 + 7, LOG = 20; const ll inf = 1e18; int n; ll a[mxN], dp[mxN][mxN]; int main() { ios :: sync_with_stdio(false), cin.tie(nullptr); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= i; ++j) dp[i][j] = -inf; } for (int i = 1; i <= n; ++i) { dp[i][1] = max(dp[i - 1][1], a[i]); for (int j = 2; j <= i && i - j > 0; ++j) dp[i][j] = max(dp[i - 1][j], dp[i - 2][j - 1] + a[i]); } for (int i = 1; i <= (n + 1) / 2; ++i) cout << dp[n][i] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...