Submission #384796

#TimeUsernameProblemLanguageResultExecution timeMemory
384796fadi57Holding (COCI20_holding)C++14
55 / 110
82 ms141420 KiB
#include<bits/stdc++.h> using namespace std; const int mx=60; int n,l,r,k; typedef long long ll; ll a[mx]; int dp[mx][mx][10010]; int solve(int i,int j,int left){ int &ret=dp[i][j][left]; if(ret!=-1){return ret;} if(i>=j){return 0;} if(j>r){return 0;} if(i>=l){return 0;} if(j-i<=left){ ret=solve(i+1,j+1,left-(j-i))+(a[j]-a[i]); } ret=max(ret,solve(i+1,j,left)); ret=max(ret,solve(i,j+1,left)); ret=max(ret,solve(i+1,j+1,left)); return ret; } int main(){ cin>>n>>l>>r>>k; l--; r--; ll sum=0; ll ans; memset(dp,-1,sizeof(dp)); for(int i=0;i<n;i++){ cin>>a[i]; if(i>=l&&i<=r){sum+=a[i];} } ans=sum; cout<<sum-solve(0,l,k); }

Compilation message (stderr)

holding.cpp: In function 'int main()':
holding.cpp:29:4: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   29 | ll ans;
      |    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...