#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
ll n, a, b, x[1001], ans = 1e9;
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> a >> b;
for (int i = 1; i <= n; i++)
cin >> x[i];
for (int i = 0; i < ( 1 << n ); i++ )
{
ll s = 0, k = 0, res = 0, seg = 1;
for (int j = 0; j < n; j++)
{
if ( (i & (1 << j)) )
{
if ( k == 0 )
{
k = 1;
res |= s;
s = x[j + 1];
seg++;
} else {
s += x[j + 1];
}
} else {
if ( k == 0 )
s += x[j + 1];
else {
res |= s;
s = x[j + 1];
k = 0;
seg++;
}
}
}
res |= s;
if (seg <= b && seg >= a )
ans = min(ans, res);
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
76 ms |
384 KB |
Output is correct |
9 |
Correct |
75 ms |
384 KB |
Output is correct |
10 |
Correct |
77 ms |
476 KB |
Output is correct |
11 |
Correct |
76 ms |
384 KB |
Output is correct |
12 |
Correct |
76 ms |
508 KB |
Output is correct |
13 |
Correct |
75 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
300 KB |
Output is correct |
15 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
11 ms |
384 KB |
Output is correct |
8 |
Correct |
77 ms |
504 KB |
Output is correct |
9 |
Correct |
78 ms |
376 KB |
Output is correct |
10 |
Correct |
76 ms |
504 KB |
Output is correct |
11 |
Correct |
75 ms |
384 KB |
Output is correct |
12 |
Correct |
75 ms |
420 KB |
Output is correct |
13 |
Correct |
76 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
75 ms |
356 KB |
Output is correct |
9 |
Correct |
75 ms |
384 KB |
Output is correct |
10 |
Correct |
75 ms |
504 KB |
Output is correct |
11 |
Correct |
76 ms |
384 KB |
Output is correct |
12 |
Correct |
75 ms |
384 KB |
Output is correct |
13 |
Correct |
75 ms |
384 KB |
Output is correct |
14 |
Correct |
154 ms |
384 KB |
Output is correct |
15 |
Execution timed out |
1057 ms |
384 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
75 ms |
384 KB |
Output is correct |
9 |
Correct |
75 ms |
384 KB |
Output is correct |
10 |
Correct |
75 ms |
504 KB |
Output is correct |
11 |
Correct |
75 ms |
384 KB |
Output is correct |
12 |
Correct |
76 ms |
384 KB |
Output is correct |
13 |
Correct |
75 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
300 KB |
Output is correct |
15 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
8 |
Correct |
77 ms |
420 KB |
Output is correct |
9 |
Correct |
77 ms |
384 KB |
Output is correct |
10 |
Correct |
77 ms |
412 KB |
Output is correct |
11 |
Correct |
88 ms |
396 KB |
Output is correct |
12 |
Correct |
78 ms |
384 KB |
Output is correct |
13 |
Correct |
77 ms |
384 KB |
Output is correct |
14 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |