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>
using namespace std;
#define int long long
const int N = 105;
int n,a,b,y[N],pre[N];
bool check(int past){
bool dp[n+1][n+1];
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 k = i-1;k>=0;k--){
int range_sum = pre[i] - pre[k];
dp[i][j] |= dp[k][j-1] & ((range_sum & past) == 0);
}
}
}
for(int i = a;i<=b;i++){
if(dp[n][i]){
return 1;
}
}
return 0;
}
void solve(){
cin >> n >> a >> b;
for(int i = 0;i<n;i++){
cin >> y[i];
}
for(int i = 0;i<n;i++){
pre[i+1] = pre[i] + y[i];
}
int dont = 0 , ans = 0;
for(int i = 30;i>=0;i--){
if(check(dont + (1<<i))){//olmadan da oluyor
dont += 1 << i;
}
else{//olmadan olmuyor
ans += 1 << i;
}
}
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
# | 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... |