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 <iostream>
using namespace std;
const int NMAX = 2e3 + 2;
int N, A, B;
int v[NMAX];
long long sp[NMAX];
bool dp[NMAX][NMAX];
bool SOL[45];
static inline void Read()
{
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cin >> N >> A >> B;
for(int i = 1; i <= N; ++i)
cin >> v[i], sp[i] = sp[i - 1] + v[i];
return;
}
static inline long long Query(int l, int r)
{
return (sp[r] - sp[l - 1]);
}
static inline bool verify(long long X, int bit)
{
if(X & (1LL << bit))
return false;
for(int i = bit + 1; i <= 40; ++i)
if((X & (1LL << i)) && !SOL[i])
return false;
return true;
}
static inline bool OK(int bit)
{
for(int i = 1; i <= N; ++i)
for(int j = 1; j <= N; ++j)
dp[i][j] = false;
dp[0][0] = true;
for(int i = 1; i <= N; ++i)
for(int k = 1; k <= i; ++k)
for(int j = 0; j < i; ++j)
dp[i][k] |= (verify(Query(j + 1, i), bit) & dp[j][k - 1]);
for(int i = A; i <= B; ++i)
if(dp[N][i])
return true;
return false;
}
static inline void Solve()
{
long long ans = 0;
for(int i = 40; i >= 0; --i) {
SOL[i] = !OK(i);
ans += (SOL[i] ? (1LL << i) : 0);
}
cout << ans << '\n';
return;
}
int main()
{
Read();
Solve();
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... |