using namespace std;
#include <iostream>
#include <cstring>
#define MAXN 2005
int N,A,B;
long long a[MAXN],pref[MAXN];
bool dp[MAXN][MAXN];
bool between(long long l,long long r,long long n) {
return (n >= l && n <= r);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N >> A >> B;
for(int i = 0;i < N;++i) {
cin >> a[i];
pref[i + 1] = a[i] + pref[i];
}
long long pre = 0;
for(int i = 30;i >= 0;--i) {
long long l = pre;
long long r = pre + (1ll << i) - 1;
// cout << pre << " " << l << " " << r << endl;
memset(dp,0,sizeof(dp));
dp[0][0] = true;
for(int j = 1;j <= N;++j) {
for(int k = 1;k <= N;++k) {
for(int t = 0;t < j;++t) {
if(dp[t][k - 1] && between(l,r,pref[j] - pref[t])) {
dp[j][k] = true;
break;
}
}
}
}
bool uwu = false;
for(int j = A;j <= B;++j) {
uwu |= dp[N][j];
}
if(!uwu) {
pre |= (1 << i);
}
}
cout << pre << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4388 KB |
Output is correct |
2 |
Incorrect |
6 ms |
4172 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4168 KB |
Output is correct |
2 |
Incorrect |
10 ms |
4172 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4168 KB |
Output is correct |
2 |
Incorrect |
5 ms |
4176 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4160 KB |
Output is correct |
2 |
Incorrect |
13 ms |
4248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4148 KB |
Output is correct |
2 |
Incorrect |
11 ms |
4152 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |