Submission #1168035

#TimeUsernameProblemLanguageResultExecution timeMemory
1168035tkm_algorithmsBali Sculptures (APIO15_sculpture)C++20
0 / 100
1095 ms840 KiB
/**
*    In the name of Allah
*    We are nothing and you're everything
*    author: najmuddin
**/
#include <bits/stdc++.h>
using namespace std;
	
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
#define int ll
 
const char nl = '\n';
const int N = 1e5+5;
const int inf = 1e8+10;

bool dp[102][202][102]; // i, jog, k

void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	
	int mx = 0;
	vector<int> arr(n+1);
	for (int i = 1; i <= n; ++i){cin >> arr[i]; mx = max(mx, n*arr[i]);}
	
	vector<int> p(n+1);
	for (int i = 1; i <= n; ++i)p[i] = arr[i], p[i] += p[i-1];
	
	
	int ans = inf;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= mx; ++j) {
			if ((p[i] | j) == j)dp[i][j][1] = 1;
			for (int k = 1; k <= b; ++k) {
				if (k != 1)
					for (int l = i-1; l >= k-1; --l) {
						if (((p[i]-p[l])|j) == j && dp[l][j][k-1] == true)dp[i][j][k] = 1;
					}
				if (i == n && dp[i][j][k] && k >= a && k <= b)ans = min(ans, j);
			}
		}
	}
	
	cout << ans;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int T = 1;
    for (int _ = 0; _ < T; ++_) {
		solve();
	}
	return 0;
}
#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...