#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn = 30;
ll arr[mxn];
ll pre[mxn];
int main()
{
int n, a, b;
cin >> n;
cin >> a >> b;
for(int i = 0; i < n; i++) cin >> arr[i];
pre[0] = arr[0];
for(int i = 1; i < n; i++) pre[i] = arr[i]+pre[i-1];
ll lim = (1<<n);
ll res = 4e18;
for(int i = 0; i < lim; i++)
{
int cnt = __builtin_popcount(i)+1;
if(cnt<a || cnt>b) continue;
ll ans = 0, last = -1;
for(int r = 0; r < n; r++)
{
ll sum = 0;
if(r&(1<<i) || r==n-1)
{
if(last==-1) sum = pre[r];
else sum = pre[r]-pre[last];
last = r;
}
ans = ans|sum;
}
res = min(res, ans);
}
cout << res << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Incorrect |
2 ms |
308 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Incorrect |
2 ms |
356 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |