Submission #967505

#TimeUsernameProblemLanguageResultExecution timeMemory
967505Tuanlinh123Candies (JOI18_candies)C++17
8 / 100
12 ms31900 KiB
#include<bits/stdc++.h> #define ll long long #define pll pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define ld long double #define sz(a) ((ll)(a).size()) using namespace std; const ll maxn=2005, inf=1e18; ll a[maxn], dp[maxn][maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; for (ll i=1; i<=n; i++) cin >> a[i]; for (ll i=0; i<=n; i++) for (ll j=1; j<=n; j++) { if (i==0) dp[i][j]=-inf; else if (i==1) dp[i][j]=j==1?a[i]:-inf; else dp[i][j]=max(dp[i-1][j], dp[i-2][j-1]+a[i]); } for (ll i=1; i<=(n+1)/2; i++) cout << dp[n][i] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...