Submission #893268

#TimeUsernameProblemLanguageResultExecution timeMemory
893268boxCandies (JOI18_candies)C++17
8 / 100
283 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #define ar array #define sz(v) int(std::size(v)) using i64 = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> A(N); for (auto &x : A) cin >> x; int take = (N + 1) / 2; vector dp(N, vector<i64>(take + 1, LLONG_MIN)); dp[0][0] = 0; for (int i = 0; i < N; i++) { if (i) dp[i] = dp[i - 1]; for (int j = 1; j <= take; j++) dp[i][j] = max(dp[i][j], (i >= 2 ? dp[i - 2][j - 1] : j == 1 ? 0 : LLONG_MIN) + A[i]); } for (int j = 1; j <= take; j++) cout << dp[N - 1][j] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...