# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017344 | vjudge1 | Holding (COCI20_holding) | C++17 | 41 ms | 4444 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=105;
int const K=10005;
int const mod=1e9+7;
int dp_pre[2][N][K],dp_suf[N][2][K];
int arr[N];
int main(){
int n,L,R,k;
cin>>n>>L>>R>>k;
for (int i = 1; i <=n; ++i)
cin>>arr[i];
int debt=0;
for (int i = L; i <=R; ++i)
debt+=arr[i];
//compute dp_pre;
for(int l=L-1;l>=1;l--)
for(int r=L;r<=R;r++)
for(int c=0;c<=k;c++){
dp_pre[l%2][r][c]=max(dp_pre[(l+1)%2][r][c],dp_pre[l%2][r-1][c]);
if(c>=r-l)
dp_pre[l%2][r][c]=max(dp_pre[l%2][r][c],dp_pre[(l+1)%2][r-1][c-(r-l)]+max(0,(arr[r]-arr[l])));
}
//compute suf_dp;
for(int r=R+1;r<=n;r++)
for(int l=R;l>=L;l--)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |