#include <bits/stdc++.h>
using namespace std;
long long dp1[2005][2005], dp2[2005], a[2005], b[2005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, l, r, loog, cur=0;
cin >> n >> l >> r;
for (long long i=1; i<=n; i++)
cin >> a[i];
for (long long i=1; i<=n; i++)
b[i]=b[i-1]+a[i];
loog=log2(b[n]);
if (l==1)
{
for (long long i=loog; i>=0; i--)
{
cur|=1<<i;
for (long long j=1; j<=n; j++)
dp2[j]=1e18;
for (long long j=1; j<=n; j++)
for (long long k=0; k<j; k++)
if (!(cur&(b[j]-b[k])))
dp2[j]=min(dp2[j], dp2[k]+1);
if (dp2[n]>r)
cur^=1<<i;
}
}
else
{
long long cur=0;
for (long long i=loog; i>=0; i--)
{
cur|=1<<i;
for (long long j=1; j<=n; j++)
for (long long k=1; k<=j; k++)
dp1[j][k]=1e18;
for (long long j=1; j<=n; j++)
{
for (long long k=1; k<=j; k++)
{
for (long long m=k-1; m<j; m++)
if (!(cur&(b[j]-b[m])))
dp1[j][k]=min(dp1[j][k], dp1[m][k-1]+1);
}
}
bool imp=1;
for (long long i=l; i<=r; i++)
{
if (dp1[n][i])
{
imp=0;
break;
}
}
if (imp)
cur^=1<<i;
}
}
cout << pow(2, loog+1)-cur-1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |