Submission #1168653

#TimeUsernameProblemLanguageResultExecution timeMemory
1168653vladiliusCandies (JOI18_candies)C++20
8 / 100
269 ms589824 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second #define V1 vector<int> #define V2 vector<V1> #define V3 vector<V2> int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<int> a(n + 1); for (int i = 1; i <= n; i++){ cin>>a[i]; } vector<vector<ll>> dp(n + 1, vector<ll>(n + 1)); for (int i = 1; i <= n; i++){ for (int j = 1; j <= (i + 1) / 2; j++){ dp[i][j] = max(dp[i - 1][j], dp[max(0, i - 2)][j - 1] + a[i]); } } for (int i = 1; i <= (n + 1) / 2; i++){ cout<<dp[n][i]<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...