This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma,bmi,bmi2")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, A, B;
ll x[2000];
int k = 0;
ll y[2000];
ll search(int i = 0)
{
if (i == n)
{
if (k < A || B < k)
return LLONG_MAX;
ll ans = 0;
for (int j = 0; j < k; j++)
ans |= y[j];
return ans;
}
ll ans = LLONG_MAX;
for (int j = 0; j < k; j++)
{
y[j] += x[i];
ans = min(ans, search(i + 1));
y[j] -= x[i];
}
y[k++] = x[i];
ans = min(ans, search(i + 1));
y[--k] = 0;
return ans;
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin >> n >> A >> B;
for (int i = 0; i < n; i++)
cin >> x[i];
sort(x, x + n);
cout << search() << '\n';
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... |