Submission #369631

#TimeUsernameProblemLanguageResultExecution timeMemory
369631Mamnoon_SiamCandies (JOI18_candies)C++17
8 / 100
1416 ms398188 KiB
#include <bits/stdc++.h> using namespace std; /* sorry, this is the bare minimum :'( */ using ll = long long; using ii = pair<int, int>; using vi = vector<int>; #define all(v) begin(v), end(v) #define sz(v) (int)(v).size() #define fi first #define se second const int N = 5005; const ll inf = 1e18; ll a[N], dp[N][N]; int main(int argc, char const *argv[]) { cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); #ifdef LOCAL freopen("in", "r", stdin); #endif int n; cin >> n; fill(dp[0]+1, dp[0]+N, -inf); ll y; cin >> y; fill(dp[1]+1, dp[1]+N, -inf); dp[1][1] = y; for(int i = 2; i <= n; ++i) { ll x; cin >> x; for(int j = 0; j <= n; ++j) { dp[i][j] = dp[i-1][j]; if(i >= 2 and j) dp[i][j] = max(dp[i][j], dp[i-2][j-1] + x); } } for(int i = 1; i <= (n-1)/2+1; ++i) { cout << dp[n][i] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...