#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
#define int long long
#define double long double
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cout << #x << " = " << x << '\n';
#define vdebug(a) cout << #a << " = "; for(auto x : a) cout << x << " "; cout << '\n';
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int INF = 1e18;
signed main(){
fastio;
int n;
int a, b;
cin >> n >> a >> b;
vector<int> v(n);
for(int &i : v){
cin >> i;
}
int ans = INF;
for(int mask = 0; mask < (1LL << (n - 1)); mask++){
int s = __builtin_popcount(mask);
s++;
if(!(a <= s && s <= b)){
continue;
}
int sum = 0;
int cur = 0;
for(int i = 0; i < n - 1; i++){
sum += v[i];
if(mask & (1LL << i)){
cur |= sum;
sum = 0;
}
}
sum += v[n - 1];
cur |= sum;
ans = min(ans, cur);
}
cout << ans << '\n';
}
/*
freopen("x.in", "r", stdin);
freopen("x.out", "w", stdout);
*/
//atilla
# | 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... |