This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
/*
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
using namespace std;
#define F first
#define S second
#define pb push_back
#define nl '\n'
#define all(z) (z).begin(), (z).end()
#define sz(x) (int) (x).size()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
long long n, m, a, b, y, x, k, ti, h;
string s, ss;
char c, ch;
long double db;
const int N = 1e5 + 7;
const int INF = INT_MAX;
int mod = 1e9 + 7;
vector<ll> v, pref;
ll ans = LLONG_MAX;
ll cur = 0;
ll cnt = 0;
void solve(int st, int prev) {
cnt++;
if (cnt == k) {
ll noww = cur;
cur |= (pref[n] - pref[prev]);
ans = min(ans, cur);
cur = noww;
cnt--;
return;
}
ll now = cur;
for (int i = st; i < n; ++i) {
cur |= (pref[i] - pref[prev]);
solve(i + 1, i);
cur = now;
}
cnt--;
}
void Main() {
cin >> n >> a >> b;
v.resize(n + 1);
pref.assign(n + 1, 0);
for (int i = 1; i <= n; ++i) {
cin >> v[i];
pref[i] = pref[i - 1] + v[i];
}
for (int i = a; i <= b; ++i) {
k = i;
solve(1, 0);
}
cout << ans;
return;
}
int main () {
IOS;
#ifdef BATYA
freopen(".in", "r", stdin);
#endif
ti = 1;
//cin >> ti;
while (ti--)
Main();
return 0;
}
//doner
# | 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... |