/**
* 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 = 1e18+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) {
dp[0][j][0] = 1;
for (int k = 1; k <= b; ++k) {
for (int l = i-1; l >= 0; --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 << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int T = 1;
for (int _ = 0; _ < T; ++_) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |