#include <bits/stdc++.h>
using namespace std;
//Fast
int main(){
int n,a,b;
cin>>n>>a>>b;
long long arr[n];
for(int i = 0;i<n;i++){
cin>>arr[i];
}
int dp[n+1] = {0};
dp[n] = 0;
long long num = (1LL<<30)-1 , sum = 0;int mi = 1e9;
for(int bi = 29;bi>=0;bi--){
num^=(1<<bi);
for(int i = n-1;i>=0;i--){
sum = arr[i];
mi = 1e9;
for(int j = i+1;j<=n;j++){
if((sum|num)==num){
mi = min(mi,dp[j]+1);
}
sum+=arr[j];
}
dp[i] = mi+1;
}
if(dp[0]>b+1){
num^=(1<<bi);
}
}
cout<<num<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |