Submission #791585

#TimeUsernameProblemLanguageResultExecution timeMemory
791585akariFeast (NOI19_feast)C++14
0 / 100
61 ms1952 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define ii pair<ll,ll> const ll maxn=2e5+2; int a[maxn]; ll dp[2002][2006]; ll ans; int main(){ int n,k; cin>>n>>k; for (int i=1;i<=n;++i) cin>>a[i]; for (int j=1;j<=k;++j){ for (int i=1;i<=n;++i){ dp[i][j]=max({dp[i-1][j]+a[i], dp[i-1][j-1]+a[i],dp[i][j],dp[i-1][j-1]}); //cout<<dp[i][j]<<" "; ans=max(ans,dp[i][j]); } //cout<<endl; } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...