Submission #1032318

# Submission time Handle Problem Language Result Execution time Memory
1032318 2024-07-23T15:44:41 Z 0pt1mus23 Holding (COCI20_holding) C++14
0 / 110
0 ms 348 KB
#pragma GCC optimize("O3", "inline")
#define skillissue <bits/stdc++.h>
#define ultra_mal std
#include skillissue
using namespace ultra_mal;
 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ins insert
#define pb push_back
#define int long long int
#define pii pair<int, int>
#define endl '\n' 
#define drop(x) cout<<(x)<<endl; return;
#define all(x) x.begin(),x.end()
#define hash FhashF
const int mod = 1e9 +7, sze = 1e4 +10, inf = LLONG_MAX, P = 1453;
// const int L = 30;

int dp[111][111][sze];
void optimus(){
    int n,l,r,k;
    cin>>n>>l>>r>>k;
    vector<int> arr(n+1);
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    int sum=0;
    for(int i = l;i<=r;i++){
        sum+=arr[i];
    }

    dp[1][l][0]=0;
    for(int i =1;i<l;i++){
        for(int j= l;j<=r;j++){
            for(int p=0;p<=k;p++){
                
                dp[i][j][p]= max({ 
                    dp[i-1][j][p],
                    dp[i][j-1][p],
                    dp[i-1][j-1][p - (j-i)]-  arr[i]+ arr[j]
                });
                // cout<<i<<" "<<j<<" "<<p<<" "<<dp[i][j][p]<<" "<<
                //     dp[i-1][j-1][p - (j-i)]+  arr[i]- arr[j]<<endl;
            }
        }
    }

    drop(sum - dp[l-1][r][k]);
}
 
signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int tt = 1;
    // cin>>tt;
    while(tt--){
        optimus();
    }
 
    return 0;
} 
 
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -