#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fb(i,b,a) for(int i=b;i>=a;i--)
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 2005;
const int inf = 1e9 + 5;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// os.order_of_key(k) the number of elements in the os less than k
// *os.find_by_order(k) print the k-th smallest number in os(0-based)
int n, A, B;
ll niz[maxn];
bool dp[maxn][maxn];
bool da_li(ll X) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
ff(i,1,n) {
ff(j,1,B) {
ll zbir = 0;
fb(l,i,1) {
zbir += niz[l];
if(!(zbir & (~X)))dp[i][j] |= dp[l - 1][j - 1];
}
}
}
ff(i,A,B) {
if(dp[n][i] == 1)return 1;
}
return 0;
}
int main()
{
ios::sync_with_stdio(false);
cout.tie(nullptr);
cin.tie(nullptr);
cin >> n >> A >> B;
ff(i,1,n)cin >> niz[i];
ll rez = (1ll << 41) - 1;
fb(mask,40,0) {
if(da_li(rez ^ (1ll << mask)))rez ^= (1ll << mask);
}
cout << rez << endl;
return 0;
}
/**
6 1 3
8 1 2 1 5 4
// probati bojenje sahovski ili slicno
**/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
4172 KB |
Output is correct |
2 |
Correct |
8 ms |
4172 KB |
Output is correct |
3 |
Correct |
8 ms |
4172 KB |
Output is correct |
4 |
Correct |
9 ms |
4172 KB |
Output is correct |
5 |
Correct |
8 ms |
4172 KB |
Output is correct |
6 |
Correct |
9 ms |
4172 KB |
Output is correct |
7 |
Correct |
9 ms |
4256 KB |
Output is correct |
8 |
Correct |
8 ms |
4172 KB |
Output is correct |
9 |
Correct |
9 ms |
4176 KB |
Output is correct |
10 |
Correct |
9 ms |
4172 KB |
Output is correct |
11 |
Correct |
10 ms |
4176 KB |
Output is correct |
12 |
Correct |
9 ms |
4172 KB |
Output is correct |
13 |
Correct |
9 ms |
4172 KB |
Output is correct |
14 |
Correct |
9 ms |
4252 KB |
Output is correct |
15 |
Correct |
8 ms |
4252 KB |
Output is correct |
16 |
Correct |
9 ms |
4172 KB |
Output is correct |
17 |
Correct |
8 ms |
4252 KB |
Output is correct |
18 |
Correct |
9 ms |
4172 KB |
Output is correct |
19 |
Correct |
9 ms |
4252 KB |
Output is correct |
20 |
Correct |
10 ms |
4172 KB |
Output is correct |
21 |
Correct |
9 ms |
4252 KB |
Output is correct |
22 |
Correct |
9 ms |
4256 KB |
Output is correct |
23 |
Correct |
9 ms |
4172 KB |
Output is correct |
24 |
Correct |
10 ms |
4256 KB |
Output is correct |
25 |
Correct |
9 ms |
4172 KB |
Output is correct |
26 |
Correct |
9 ms |
4172 KB |
Output is correct |
27 |
Correct |
9 ms |
4172 KB |
Output is correct |
28 |
Correct |
9 ms |
4256 KB |
Output is correct |
29 |
Correct |
8 ms |
4172 KB |
Output is correct |
30 |
Correct |
8 ms |
4172 KB |
Output is correct |
31 |
Correct |
9 ms |
4172 KB |
Output is correct |
32 |
Correct |
8 ms |
4256 KB |
Output is correct |
33 |
Correct |
9 ms |
4172 KB |
Output is correct |
34 |
Correct |
10 ms |
4164 KB |
Output is correct |
35 |
Correct |
9 ms |
4172 KB |
Output is correct |
36 |
Correct |
9 ms |
4172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
4256 KB |
Output is correct |
2 |
Correct |
9 ms |
4260 KB |
Output is correct |
3 |
Correct |
8 ms |
4256 KB |
Output is correct |
4 |
Correct |
8 ms |
4172 KB |
Output is correct |
5 |
Correct |
8 ms |
4172 KB |
Output is correct |
6 |
Correct |
8 ms |
4172 KB |
Output is correct |
7 |
Correct |
9 ms |
4164 KB |
Output is correct |
8 |
Correct |
8 ms |
4172 KB |
Output is correct |
9 |
Correct |
9 ms |
4168 KB |
Output is correct |
10 |
Correct |
8 ms |
4260 KB |
Output is correct |
11 |
Correct |
9 ms |
4168 KB |
Output is correct |
12 |
Correct |
8 ms |
4252 KB |
Output is correct |
13 |
Correct |
9 ms |
4172 KB |
Output is correct |
14 |
Correct |
9 ms |
4256 KB |
Output is correct |
15 |
Correct |
9 ms |
4172 KB |
Output is correct |
16 |
Correct |
9 ms |
4256 KB |
Output is correct |
17 |
Correct |
9 ms |
4172 KB |
Output is correct |
18 |
Correct |
9 ms |
4172 KB |
Output is correct |
19 |
Correct |
9 ms |
4172 KB |
Output is correct |
20 |
Correct |
9 ms |
4172 KB |
Output is correct |
21 |
Correct |
9 ms |
4264 KB |
Output is correct |
22 |
Correct |
9 ms |
4172 KB |
Output is correct |
23 |
Correct |
11 ms |
4164 KB |
Output is correct |
24 |
Correct |
9 ms |
4172 KB |
Output is correct |
25 |
Correct |
9 ms |
4256 KB |
Output is correct |
26 |
Correct |
9 ms |
4260 KB |
Output is correct |
27 |
Correct |
10 ms |
4168 KB |
Output is correct |
28 |
Correct |
9 ms |
4260 KB |
Output is correct |
29 |
Correct |
9 ms |
4172 KB |
Output is correct |
30 |
Correct |
9 ms |
4172 KB |
Output is correct |
31 |
Correct |
10 ms |
4168 KB |
Output is correct |
32 |
Correct |
10 ms |
4256 KB |
Output is correct |
33 |
Correct |
9 ms |
4256 KB |
Output is correct |
34 |
Correct |
11 ms |
4168 KB |
Output is correct |
35 |
Correct |
12 ms |
4168 KB |
Output is correct |
36 |
Correct |
9 ms |
4252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
4256 KB |
Output is correct |
2 |
Correct |
10 ms |
4172 KB |
Output is correct |
3 |
Correct |
9 ms |
4172 KB |
Output is correct |
4 |
Correct |
11 ms |
4172 KB |
Output is correct |
5 |
Correct |
10 ms |
4256 KB |
Output is correct |
6 |
Correct |
9 ms |
4256 KB |
Output is correct |
7 |
Correct |
8 ms |
4252 KB |
Output is correct |
8 |
Correct |
9 ms |
4252 KB |
Output is correct |
9 |
Correct |
8 ms |
4172 KB |
Output is correct |
10 |
Correct |
9 ms |
4300 KB |
Output is correct |
11 |
Correct |
8 ms |
4172 KB |
Output is correct |
12 |
Correct |
8 ms |
4172 KB |
Output is correct |
13 |
Correct |
9 ms |
4256 KB |
Output is correct |
14 |
Correct |
10 ms |
4172 KB |
Output is correct |
15 |
Correct |
9 ms |
4172 KB |
Output is correct |
16 |
Correct |
10 ms |
4300 KB |
Output is correct |
17 |
Correct |
12 ms |
4172 KB |
Output is correct |
18 |
Correct |
12 ms |
4172 KB |
Output is correct |
19 |
Correct |
10 ms |
4172 KB |
Output is correct |
20 |
Correct |
9 ms |
4256 KB |
Output is correct |
21 |
Correct |
10 ms |
4172 KB |
Output is correct |
22 |
Correct |
10 ms |
4172 KB |
Output is correct |
23 |
Correct |
10 ms |
4312 KB |
Output is correct |
24 |
Correct |
11 ms |
4184 KB |
Output is correct |
25 |
Correct |
10 ms |
4184 KB |
Output is correct |
26 |
Correct |
15 ms |
4268 KB |
Output is correct |
27 |
Correct |
29 ms |
4184 KB |
Output is correct |
28 |
Correct |
52 ms |
4176 KB |
Output is correct |
29 |
Correct |
54 ms |
4172 KB |
Output is correct |
30 |
Correct |
9 ms |
4184 KB |
Output is correct |
31 |
Correct |
29 ms |
4172 KB |
Output is correct |
32 |
Correct |
41 ms |
4172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
4252 KB |
Output is correct |
2 |
Correct |
9 ms |
4172 KB |
Output is correct |
3 |
Correct |
9 ms |
4256 KB |
Output is correct |
4 |
Correct |
9 ms |
4260 KB |
Output is correct |
5 |
Correct |
9 ms |
4172 KB |
Output is correct |
6 |
Correct |
9 ms |
4172 KB |
Output is correct |
7 |
Correct |
9 ms |
4168 KB |
Output is correct |
8 |
Correct |
9 ms |
4172 KB |
Output is correct |
9 |
Correct |
11 ms |
4168 KB |
Output is correct |
10 |
Correct |
9 ms |
4256 KB |
Output is correct |
11 |
Correct |
9 ms |
4172 KB |
Output is correct |
12 |
Correct |
9 ms |
4172 KB |
Output is correct |
13 |
Correct |
8 ms |
4164 KB |
Output is correct |
14 |
Correct |
8 ms |
4176 KB |
Output is correct |
15 |
Correct |
8 ms |
4172 KB |
Output is correct |
16 |
Correct |
9 ms |
4172 KB |
Output is correct |
17 |
Correct |
9 ms |
4300 KB |
Output is correct |
18 |
Correct |
8 ms |
4176 KB |
Output is correct |
19 |
Correct |
9 ms |
4172 KB |
Output is correct |
20 |
Correct |
10 ms |
4172 KB |
Output is correct |
21 |
Correct |
9 ms |
4172 KB |
Output is correct |
22 |
Correct |
9 ms |
4172 KB |
Output is correct |
23 |
Correct |
9 ms |
4172 KB |
Output is correct |
24 |
Correct |
9 ms |
4172 KB |
Output is correct |
25 |
Correct |
8 ms |
4172 KB |
Output is correct |
26 |
Correct |
10 ms |
4232 KB |
Output is correct |
27 |
Correct |
8 ms |
4260 KB |
Output is correct |
28 |
Correct |
8 ms |
4256 KB |
Output is correct |
29 |
Correct |
8 ms |
4172 KB |
Output is correct |
30 |
Correct |
8 ms |
4172 KB |
Output is correct |
31 |
Correct |
9 ms |
4172 KB |
Output is correct |
32 |
Correct |
9 ms |
4172 KB |
Output is correct |
33 |
Correct |
10 ms |
4300 KB |
Output is correct |
34 |
Correct |
8 ms |
4172 KB |
Output is correct |
35 |
Correct |
9 ms |
4172 KB |
Output is correct |
36 |
Correct |
9 ms |
4172 KB |
Output is correct |
37 |
Correct |
9 ms |
4256 KB |
Output is correct |
38 |
Correct |
11 ms |
4172 KB |
Output is correct |
39 |
Correct |
10 ms |
4172 KB |
Output is correct |
40 |
Correct |
10 ms |
4172 KB |
Output is correct |
41 |
Correct |
10 ms |
4256 KB |
Output is correct |
42 |
Correct |
10 ms |
4172 KB |
Output is correct |
43 |
Correct |
9 ms |
4260 KB |
Output is correct |
44 |
Correct |
10 ms |
4172 KB |
Output is correct |
45 |
Correct |
12 ms |
4172 KB |
Output is correct |
46 |
Correct |
10 ms |
4256 KB |
Output is correct |
47 |
Correct |
11 ms |
4260 KB |
Output is correct |
48 |
Correct |
10 ms |
4172 KB |
Output is correct |
49 |
Correct |
14 ms |
4264 KB |
Output is correct |
50 |
Correct |
28 ms |
4172 KB |
Output is correct |
51 |
Correct |
51 ms |
4172 KB |
Output is correct |
52 |
Correct |
53 ms |
4236 KB |
Output is correct |
53 |
Correct |
9 ms |
4172 KB |
Output is correct |
54 |
Correct |
29 ms |
4260 KB |
Output is correct |
55 |
Correct |
41 ms |
4252 KB |
Output is correct |
56 |
Correct |
10 ms |
4168 KB |
Output is correct |
57 |
Correct |
13 ms |
4260 KB |
Output is correct |
58 |
Correct |
23 ms |
4256 KB |
Output is correct |
59 |
Correct |
52 ms |
4236 KB |
Output is correct |
60 |
Correct |
47 ms |
4240 KB |
Output is correct |
61 |
Correct |
9 ms |
4172 KB |
Output is correct |
62 |
Correct |
40 ms |
4172 KB |
Output is correct |
63 |
Correct |
39 ms |
4172 KB |
Output is correct |
64 |
Correct |
45 ms |
4172 KB |
Output is correct |
65 |
Correct |
14 ms |
4172 KB |
Output is correct |
66 |
Correct |
11 ms |
4172 KB |
Output is correct |
67 |
Correct |
14 ms |
4172 KB |
Output is correct |
68 |
Correct |
22 ms |
4164 KB |
Output is correct |
69 |
Correct |
40 ms |
4172 KB |
Output is correct |
70 |
Correct |
37 ms |
4176 KB |
Output is correct |
71 |
Correct |
9 ms |
4172 KB |
Output is correct |
72 |
Correct |
40 ms |
4172 KB |
Output is correct |
73 |
Correct |
33 ms |
4236 KB |
Output is correct |
74 |
Correct |
29 ms |
4172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
4256 KB |
Output is correct |
2 |
Correct |
8 ms |
4172 KB |
Output is correct |
3 |
Correct |
9 ms |
4176 KB |
Output is correct |
4 |
Correct |
11 ms |
4172 KB |
Output is correct |
5 |
Correct |
8 ms |
4172 KB |
Output is correct |
6 |
Correct |
9 ms |
4172 KB |
Output is correct |
7 |
Correct |
9 ms |
4172 KB |
Output is correct |
8 |
Correct |
9 ms |
4172 KB |
Output is correct |
9 |
Correct |
9 ms |
4172 KB |
Output is correct |
10 |
Correct |
9 ms |
4172 KB |
Output is correct |
11 |
Correct |
8 ms |
4248 KB |
Output is correct |
12 |
Correct |
9 ms |
4172 KB |
Output is correct |
13 |
Correct |
9 ms |
4172 KB |
Output is correct |
14 |
Correct |
9 ms |
4252 KB |
Output is correct |
15 |
Correct |
9 ms |
4172 KB |
Output is correct |
16 |
Correct |
10 ms |
4172 KB |
Output is correct |
17 |
Correct |
10 ms |
4172 KB |
Output is correct |
18 |
Correct |
10 ms |
4172 KB |
Output is correct |
19 |
Correct |
9 ms |
4172 KB |
Output is correct |
20 |
Correct |
9 ms |
4164 KB |
Output is correct |
21 |
Correct |
8 ms |
4172 KB |
Output is correct |
22 |
Correct |
8 ms |
4172 KB |
Output is correct |
23 |
Correct |
9 ms |
4172 KB |
Output is correct |
24 |
Correct |
9 ms |
4172 KB |
Output is correct |
25 |
Correct |
9 ms |
4172 KB |
Output is correct |
26 |
Correct |
9 ms |
4172 KB |
Output is correct |
27 |
Correct |
10 ms |
4172 KB |
Output is correct |
28 |
Correct |
11 ms |
4256 KB |
Output is correct |
29 |
Correct |
13 ms |
4172 KB |
Output is correct |
30 |
Correct |
9 ms |
4172 KB |
Output is correct |
31 |
Correct |
14 ms |
4172 KB |
Output is correct |
32 |
Correct |
13 ms |
4256 KB |
Output is correct |
33 |
Correct |
10 ms |
4256 KB |
Output is correct |
34 |
Correct |
10 ms |
4172 KB |
Output is correct |
35 |
Correct |
10 ms |
4260 KB |
Output is correct |
36 |
Correct |
17 ms |
4172 KB |
Output is correct |
37 |
Correct |
29 ms |
4172 KB |
Output is correct |
38 |
Correct |
52 ms |
4172 KB |
Output is correct |
39 |
Correct |
51 ms |
4172 KB |
Output is correct |
40 |
Correct |
10 ms |
4172 KB |
Output is correct |
41 |
Correct |
31 ms |
4172 KB |
Output is correct |
42 |
Correct |
47 ms |
4172 KB |
Output is correct |
43 |
Correct |
10 ms |
4260 KB |
Output is correct |
44 |
Correct |
13 ms |
4264 KB |
Output is correct |
45 |
Correct |
22 ms |
4260 KB |
Output is correct |
46 |
Correct |
37 ms |
4172 KB |
Output is correct |
47 |
Correct |
37 ms |
4172 KB |
Output is correct |
48 |
Correct |
9 ms |
4172 KB |
Output is correct |
49 |
Correct |
44 ms |
4252 KB |
Output is correct |
50 |
Correct |
48 ms |
4172 KB |
Output is correct |
51 |
Correct |
15 ms |
4172 KB |
Output is correct |
52 |
Correct |
838 ms |
4244 KB |
Output is correct |
53 |
Execution timed out |
1085 ms |
4172 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |