Submission #384791

#TimeUsernameProblemLanguageResultExecution timeMemory
384791fadi57Holding (COCI20_holding)C++14
0 / 110
1 ms364 KiB
#include<bits/stdc++.h> using namespace std; const int mx=14; int n,l,r,k; typedef long long ll; ll a[20]; int dp[mx][mx][10000]; int solve(int i,int j,int left){ int ret=0; 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; for(int i=0;i<n;i++){ cin>>a[i]; if(i>=l&&i<=r){sum+=a[i];} } ans=sum; cout<<solve(0,l,k); }

Compilation message (stderr)

holding.cpp: In function 'int main()':
holding.cpp:28:4: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   28 | 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...