Submission #1213979

#TimeUsernameProblemLanguageResultExecution timeMemory
1213979namhhCandies (JOI18_candies)C++20
8 / 100
20 ms23112 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define fi first #define se second const int N = 2e3+1; int n,a[N],dp[N][1001][2]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); 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+1)/2; j++){ dp[i][j][0] = max(dp[i-1][j][1],dp[i-1][j][0]); dp[i][j][1] = dp[i-1][j-1][0]+a[i]; } } for(int j = 1; j <= (n+1)/2; j++){ int ans = 0; for(int i = 1; i <= n; i++) ans = max(ans,max(dp[i][j][0],dp[i][j][1])); cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...