# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
384796 |
2021-04-02T09:44:31 Z |
fadi57 |
Holding (COCI20_holding) |
C++14 |
|
82 ms |
141420 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
77 ms |
141420 KB |
Output is correct |
2 |
Correct |
78 ms |
141420 KB |
Output is correct |
3 |
Correct |
78 ms |
141420 KB |
Output is correct |
4 |
Correct |
77 ms |
141420 KB |
Output is correct |
5 |
Correct |
77 ms |
141420 KB |
Output is correct |
6 |
Correct |
79 ms |
141420 KB |
Output is correct |
7 |
Correct |
78 ms |
141420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
141420 KB |
Output is correct |
2 |
Correct |
78 ms |
141420 KB |
Output is correct |
3 |
Correct |
78 ms |
141420 KB |
Output is correct |
4 |
Correct |
77 ms |
141420 KB |
Output is correct |
5 |
Correct |
77 ms |
141420 KB |
Output is correct |
6 |
Correct |
79 ms |
141420 KB |
Output is correct |
7 |
Correct |
78 ms |
141420 KB |
Output is correct |
8 |
Correct |
78 ms |
141420 KB |
Output is correct |
9 |
Correct |
78 ms |
141420 KB |
Output is correct |
10 |
Correct |
78 ms |
141420 KB |
Output is correct |
11 |
Correct |
81 ms |
141316 KB |
Output is correct |
12 |
Correct |
78 ms |
141420 KB |
Output is correct |
13 |
Correct |
82 ms |
141324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
141420 KB |
Output is correct |
2 |
Correct |
78 ms |
141420 KB |
Output is correct |
3 |
Correct |
78 ms |
141420 KB |
Output is correct |
4 |
Correct |
77 ms |
141420 KB |
Output is correct |
5 |
Correct |
77 ms |
141420 KB |
Output is correct |
6 |
Correct |
79 ms |
141420 KB |
Output is correct |
7 |
Correct |
78 ms |
141420 KB |
Output is correct |
8 |
Correct |
78 ms |
141420 KB |
Output is correct |
9 |
Correct |
78 ms |
141420 KB |
Output is correct |
10 |
Correct |
78 ms |
141420 KB |
Output is correct |
11 |
Correct |
81 ms |
141316 KB |
Output is correct |
12 |
Correct |
78 ms |
141420 KB |
Output is correct |
13 |
Correct |
82 ms |
141324 KB |
Output is correct |
14 |
Correct |
78 ms |
141420 KB |
Output is correct |
15 |
Correct |
81 ms |
141420 KB |
Output is correct |
16 |
Incorrect |
79 ms |
141420 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
141420 KB |
Output is correct |
2 |
Correct |
78 ms |
141420 KB |
Output is correct |
3 |
Correct |
78 ms |
141420 KB |
Output is correct |
4 |
Correct |
77 ms |
141420 KB |
Output is correct |
5 |
Correct |
77 ms |
141420 KB |
Output is correct |
6 |
Correct |
79 ms |
141420 KB |
Output is correct |
7 |
Correct |
78 ms |
141420 KB |
Output is correct |
8 |
Correct |
78 ms |
141420 KB |
Output is correct |
9 |
Correct |
78 ms |
141420 KB |
Output is correct |
10 |
Correct |
78 ms |
141420 KB |
Output is correct |
11 |
Correct |
81 ms |
141316 KB |
Output is correct |
12 |
Correct |
78 ms |
141420 KB |
Output is correct |
13 |
Correct |
82 ms |
141324 KB |
Output is correct |
14 |
Correct |
78 ms |
141420 KB |
Output is correct |
15 |
Correct |
81 ms |
141420 KB |
Output is correct |
16 |
Incorrect |
79 ms |
141420 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |