#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
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 time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |