Submission #844595

# Submission time Handle Problem Language Result Execution time Memory
844595 2023-09-05T14:27:26 Z vjudge1 Holding (COCI20_holding) C++17
0 / 110
0 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define all(c) (c).begin(), (c).end()

void solve(){	

	int n,l,r,k;
	cin >> n >> l >> r >> k;

	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}

	int ans = 1e18;
	for(int i = 0; i < (1 << n); i++){
			
		int fuck = 0;
		for(int j = 0; j < n; j++){
			fuck += !!(1 << j & i);
		}	

		if(fuck != n - l + 1) continue;

		int cnt = 0,val = 0,cost = 0;
		for(int j = 0; j < n; j++){
			if(!(i & 1 << j)) continue;
			if(j < l){
				cost += (l - j + cnt);
				val += v[j];
				++cnt;
			}
			else val += v[j],cnt++;
		}
		if(k >= cost){
			ans = min(ans,val);
		}
	}

	cout << ans << endl;
}

signed main(){

	#ifndef ONLINE_JUDGE
	//	freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
	#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;
//	cin >> t;

	while(t--){
		solve();
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -