제출 #1071558

#제출 시각아이디문제언어결과실행 시간메모리
1071558MuhammetBali Sculptures (APIO15_sculpture)C++17
37 / 100
13 ms604 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define sz(x) (int)x.size()
#define ff first
#define ss second

const ll N = 305;
const ll M = 1e9 + 7;

ll T, n, c[N], d[N], a, b;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> n >> a >> b;
	vector <int> p(n+1,0);
	for(int i = 1; i <= n; i++){
		cin >> c[i];
		p[i] = p[i-1] + c[i];
	}

	ll s = 0, ans = p[n];
	for(int i = 1; i <= n; i++){
		s += c[i];
		vector <vector <ll>> dp(n+1, vector <ll> (n+1,1e9));
		for(int j = i+1; j <= n; j++){
			dp[j][1] = (p[j]-p[i])|s;
			for(int j1 = j-1; j1 > i; j1--){
				for(int ste = 1; ste < n; ste++){
					dp[j][ste+1] = min(dp[j][ste+1],(dp[j1][ste]|(p[j]-p[j1]))|s);
				}
			}
		}
		for(int j = a-1; j < b; j++){
			ans = min(ans,dp[n][j]);
		}
	}

	cout << ans << "\n";

	return 0;
}
// 6 1 3
// 8 1 2 1 5 4
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...