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>
#define st first
#define nd second
using namespace std;
const long long INF = 1e12;
const int MOD = 1e9+7;
const int MAXN = 30000;
int n, l, r;
long long v[100];
long long func(int f, int k, int cnt, long long sum, long long orr) {
long long ans = INF;
if(k > r) return INF;
if(f == n+1) {
if(k < l || k > r) return INF;
//cout << f << " " << k << " " << (orr|sum) << endl;
return orr|sum;
}
ans = func(f+1,k,cnt+1,sum+v[f],orr);
if(cnt != 0)
ans = min(ans,func(f+1,k+1,1,v[f],sum|orr));
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> l >> r;
for(int i = 1; i <= n; i++)
cin >> v[i];
cout << func(1,1,0,0,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... |