#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];
bool dp[maxn][maxn][maxn][32];
void recur(int pos, int lpos, int knum, int Or){
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;
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 = 0; i <= n; i++)
for(int j = A; j <= B; j++)
for(int k = 0; k < 32; k++)
if(dp[n+1][i][j][k]) ans = min(ans, k);
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |