#include<bits/stdc++.h>
using namespace std;
const int nax = 2001;
int n, a, b;
long long ans;
int curBit;
int dp[nax][nax];
int tree[nax];
bool good(long long S) {
if(S>>curBit&1) return false;
for(int j=curBit+1; j<44; ++j) {
if((S>>j&1) && (~ans>>j&1)) return false;
}
return true;
}
int solve(int i, int j) {
if(i>n) return j>=a && j<=b;
int &ret = dp[i][j];
if(ret!=-1) return ret;
ret = 0;
long long S = 0;
int mx = -1;
for(int k=i; k<=n; ++k) {
S += tree[k];
if(good(S)) ret |= solve(k+1, j+1), mx = k;
}
if(ret) assert(solve(mx+1, j+1));
return ret;
}
void PlayGround() {
cin>>n>>a>>b;
for(int i=1; i<=n; ++i) {
cin>>tree[i];
}
for(int i=44; i>=0; --i) {
curBit = i;
memset(dp, -1, sizeof dp);
if(!solve(1, 0)) ans |= 1LL<<i;
}
cout<<ans<<'\n';
// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
104 ms |
32248 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
92 ms |
32240 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
97 ms |
32192 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
99 ms |
32224 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
103 ms |
32228 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |