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>
using namespace std;
const int nx=105;
int n, a, b, x, vl[nx], dp[nx][nx], msk, sm;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>a>>b;
for (int i=1; i<=n; i++) cin>>vl[i], sm+=vl[i];
dp[0][0]=1;
for (int x=0; x<=sm; x++)
{
for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) dp[i][j]=0;
for (int i=1; i<=n; i++)
{
for (int j=1; j<=n; j++)
{
msk=vl[i];
for (int k=i-1; k>=0; k--)
{
if ((msk|x)==x&&dp[k][j-1]) dp[i][j]|=1;
msk+=vl[k];
}
}
}
for (int j=a; j<=b; j++) if (dp[n][j]) return cout<<x, 0;
}
}
/*
6 1 3
8 1 2 1 5 4
*/
# | 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... |