Submission #499989

# Submission time Handle Problem Language Result Execution time Memory
499989 2021-12-30T08:22:25 Z inksamurai Holding (COCI20_holding) C++17
0 / 110
1 ms 204 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define crep(i,x,n) for(ll i=x;i<n;i++)
#define drep(i,n) for(ll i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<ll,ll>;
using vi=vector<ll>;
using vll=vector<long long>;

const ll inf=1e18;

int main(){
_3qplfh5;
	ll n,l,r,k;
	cin>>n>>l>>r>>k;
	vi a(n);
	rep(i,n){
		cin>>a[i];
	}
	assert(r==n);
	l--,r--;
	vi rbts;
	crep(i,l,r+1){
		rbts.pb(a[i]);
	}
	ll m=r-l+1;
	vi psum=rbts;
	crep(i,1,m){
		psum[i]+=psum[i-1];
	}
	vec(vi) dp(m+1,vi(k+1,inf)),nedp;
	dp[0][0]=psum[m-1];
	dp[m][0]=0;
	drep(i,l){
		nedp=dp;
		ll x=a[i];
		rep(cost,k+1){
			rep(j,m+1){
				if(dp[j][cost]==inf) continue;
				rep(j1,j){
					ll necost=cost+j1+l-i;
					ll now=psum[j-1]-psum[j1];
					if(necost>k) continue;
					// if(i==2 and cost==0 and j==m) cout<<j1<<" "<<necost<<" "<<now<<"\n";
					nedp[j1][necost]=min(nedp[j1][necost],dp[j][cost]+x+now);
				}
			}
		}
		swap(dp,nedp);
		// if(i==3) cout<<dp[0][1]<<"\n";
	}
	ll ans=inf;
	rep(i,k+1){
		ans=min(ans,dp[0][i]);
	}
	cout<<ans<<"\n";
//
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -