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 mp make_pair
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
typedef long double ld;
using namespace std;
int n, a, b;
ll num[2005], pre[2050];
ll dp[2005], dp2[2005][2005];
ll bit = 43, mask;
ll c(int i, int j) {
return pre[j] - pre[i-1];
}
void can(int x) {
mask ^= (1LL << x);
for(int i = 1; i <= n; i++) {
dp[i] = 1e18+7;
for(int j = 0; j < i; j++) {
if((mask | c(j+1, i)) == mask) dp[i] = min(dp[i], dp[j]+1);
}
}
if(dp[n] > b) mask |= (1LL << x);
}
void can2(int x) {
mask ^= (1LL << x);
memset(dp2, 0, sizeof dp2);
dp2[0][0] = 1;
for(int k = 1; k <= n; k++) {
for(int i = 1; i <= n; i++) {
for(int j = 0; j < i; j++) {
if((mask | c(j+1, i)) == mask) dp2[k][i] |= dp2[k-1][j];
}
}
}
for(int i = a; i <= b; i++) if(dp2[i][n]) return;
mask |= (1LL << x);
}
int main()
{
cin >> n >> a >> b;
ll mn = 1e18+7;
for(int i = 1; i <= n; i++) cin >> num[i];
for(int i = 1; i <= n; i++) pre[i] = pre[i-1] + num[i];
for(int i = 0; i <= bit; i++) mask |= (1LL << i);
for(int i = bit; i >= 0; i--) can2(i);
cout << mask << endl;
return 0;
}
Compilation message (stderr)
sculpture.cpp: In function 'int main()':
sculpture.cpp:53:5: warning: unused variable 'mn' [-Wunused-variable]
ll mn = 1e18+7;
^~
# | 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... |