#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = (int)1e2+10;
const int LINF = (int)1e18;
int n, A, B, ans=LINF;
int a[maxn], pre[maxn];
int dp[maxn][maxn][maxn][32];
void recur(int pos, int lpos, int knum, int Or){
if(dp[pos][lpos][knum][Or]!=-1) return;
dp[pos][lpos][knum][Or]=1;
if(pos==n+1) return;
if(pos!=n) recur(pos+1, lpos, knum, Or);
recur(pos+1, pos, knum+1, Or|(pre[pos]-pre[lpos]));
}
int32_t main() {
cin >> n >> A >> B; memset(dp,-1,sizeof(dp));
for(int i = 0; i < n; i++) cin >> a[i], pre[i+1]=pre[i]+a[i];
recur(1,0,1,0);
for(int i = A+1; i <= B+1; i++)
for(int k = 0; k < 32; k++)
if(dp[n+1][n][i][k]==1) ans = min(ans, k);
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
103 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
100 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
104 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
102 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
103 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |