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 = 1e9;
const int MOD = 1e9+7;
const int MAXN = 30000;
int n, l, r;
int v[100];
int func(int f, int k, int cnt, int sum, int orr) {
int 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... |