답안 #844605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844605 2023-09-05T14:30:08 Z vjudge1 Holding (COCI20_holding) C++17
0 / 110
0 ms 348 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],cost -= j;
		}
		if(k >= cost + (n - l) * (n - l + 1) / 2){
			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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -