This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/// adil sultanov | vonat1us
#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
void fin() {
#ifdef AM
freopen(".in", "r", stdin);
#endif
}
const bool flag = 0;
const int N = 2e3+10;
void ma1n() {
int n, L, R;
cin >> n >> L >> R;
vector<ll> a(n);
for (ll& x : a) cin >> x;
ll ans = (1ll<<50);
for (int mask = 0; mask < (1<<(n-1)); ++mask) {
int cnt = __builtin_popcount(mask)+1;
if (cnt < L || cnt > R) continue;
ll res = 0, sum = 0;
for (int i = 0; i < n; ++i) {
sum += a[i];
if (i == n-1 || mask>>i&1) {
res |= sum;
sum = 0;
}
}
ans = min(ans, res);
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(nullptr), fin();
int ts = 1;
if (flag) {
cin >> ts;
}
while (ts--) {
ma1n();
}
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... |