# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45828 | antimirage | Bali Sculptures (APIO15_sculpture) | C++17 | 85 ms | 1072 KiB |
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 fr first
#define sc second
#define mk make_pair
#define pb push_back
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 105;
int n, a, b, ar[N], cnt;
bool dp[N][N];
long long ans, sum, pref[N];
main()
{
cin >> n >> a >> b;
for (int i = 1; i <= n; i++)
scanf("%d", &ar[i]), pref[i] = pref[i - 1] + ar[i];
for (int k = 40; k >= 0; k--)
{
long long cur = (1LL << k);
memset(dp, 0, sizeof(dp) );
dp[0][0] = 1;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
for (int l = 1; l <= j; l++)
{
if ( ( ans | ( ( (pref[j] - pref[l - 1]) >> k) << k) ) == ans )
dp[i][j] |= dp[i - 1][l - 1];
}
}
}
bool fl = 0;
for (int i = a; i <= b; i++)
fl |= dp[i][n];
if (!fl)
ans += cur;
}
cout << ans << endl;
}
/**
6 1 3
8 1 2 1 5 4
**/
Compilation message (stderr)
# | 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... |