Submission #274142

#TimeUsernameProblemLanguageResultExecution timeMemory
274142okaragulCandies (JOI18_candies)C++17
8 / 100
200 ms38136 KiB
#include<bits/stdc++.h> using namespace std; #define lli long long #define INF LONG_LONG_MAX #define pb push_back #define mp make_pair #define st first #define nd second #define endl '\n' #define max(aa, bb) (aa > bb ? aa:bb) #define min(aa, bb) (aa < bb ? aa:bb) #define all(aa) aa.begin(), aa.end() int main(){ #ifdef ONLINE_JUDGE freopen("zgir.gir", "r", stdin); freopen("zcik.cik", "w", stdout); #endif lli n; cin>>n; vector<lli> v(n); for(auto &it:v) cin>>it; lli dp[2006][1006]; memset(dp, -1, sizeof(dp)); function<lli(lli, lli)> f= [&] (lli i, lli r) -> lli{ if(r<=0) return 0; if(i>=n) return -INF; if(dp[i][r]!=-1) return dp[i][r]; return dp[i][r]=max(f(i+2, r-1)+v[i], f(i+1, r)); }; for(lli j=1;j<=(n+1)/2;j++){ cout<<f(0, j)<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...