#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define bug cout << "bug" << endl
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pll pair <ll, ll>
#define pii pair <int, int>
#define triple pair <pair <ll, ll> , ll>
#define ull unsigned long long
#define ld long double
#define pinode pair <node*, node*>
const ll INF = 9e18 + 5;
const ll inf = 1e9 + 5;
const ll N = 100 + 5;
const ll shift = 2e6;
const ll mod = 998244353;
const ll mod2 = 1e9 + 9;
const ll M = 1e3 + 5;
const ll LOG = 21;
const ll sp = 263;
const ll sp2 = 9973;
const int block = 100;
const double eps = 1e-10;
ll n, a, b, Y[N], dp[N][505][N], pref[N], max_value, ans = INF;
int main(){
speed;
cin >> n >> a >> b;
for(int i = 1; i <= n; i++){
cin >> Y[i];
pref[i] = pref[i - 1] + Y[i];
}
max_value = 10 * n;
for(int i = 0; i <= n; i++){
for(int j = 0; j <= max_value; j++){
for(int z = 0; z <= n; z++){
dp[i][j][z] = 0;
}
}
}
dp[0][0][0] = 1;
for(int i = 1; i <= n; i++){
for(int j = 0; j < i; j++){
for(int curor = 0; curor <= max_value; curor++){
for(int part = 0; part < n; part++){
ll sum = pref[i] - pref[j];
if(!dp[j][curor][part])
continue;
dp[i][(curor | sum)][part + 1] = 1;
}
}
}
}
for(ll curor = 0; curor <= max_value; curor++){
for(int part = a; part <= b; part++){
if(dp[n][curor][part] == 0)
continue;
ans = min(ans, curor);
}
}
cout << ans << endl;
}
/*
%I64d6
6 1 3
8 1 2 1 5 4
5 4 4
3 5 6 6 2
%I64d
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
852 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
2260 KB |
Output is correct |
7 |
Correct |
2 ms |
2900 KB |
Output is correct |
8 |
Correct |
3 ms |
3784 KB |
Output is correct |
9 |
Correct |
3 ms |
3796 KB |
Output is correct |
10 |
Correct |
4 ms |
3796 KB |
Output is correct |
11 |
Correct |
3 ms |
3796 KB |
Output is correct |
12 |
Correct |
3 ms |
3796 KB |
Output is correct |
13 |
Correct |
3 ms |
3796 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
596 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
1 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
2 ms |
2900 KB |
Output is correct |
21 |
Correct |
4 ms |
3796 KB |
Output is correct |
22 |
Correct |
3 ms |
3796 KB |
Output is correct |
23 |
Correct |
4 ms |
3784 KB |
Output is correct |
24 |
Correct |
3 ms |
3784 KB |
Output is correct |
25 |
Correct |
3 ms |
3796 KB |
Output is correct |
26 |
Correct |
3 ms |
3796 KB |
Output is correct |
27 |
Runtime error |
2 ms |
980 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
852 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
2260 KB |
Output is correct |
7 |
Correct |
2 ms |
2900 KB |
Output is correct |
8 |
Correct |
3 ms |
3784 KB |
Output is correct |
9 |
Correct |
3 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
3796 KB |
Output is correct |
11 |
Correct |
3 ms |
3796 KB |
Output is correct |
12 |
Correct |
3 ms |
3780 KB |
Output is correct |
13 |
Correct |
3 ms |
3796 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
708 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
1 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
3 ms |
2900 KB |
Output is correct |
21 |
Correct |
3 ms |
3796 KB |
Output is correct |
22 |
Correct |
3 ms |
3796 KB |
Output is correct |
23 |
Correct |
3 ms |
3796 KB |
Output is correct |
24 |
Correct |
3 ms |
3788 KB |
Output is correct |
25 |
Correct |
3 ms |
3796 KB |
Output is correct |
26 |
Correct |
3 ms |
3784 KB |
Output is correct |
27 |
Correct |
4 ms |
4180 KB |
Output is correct |
28 |
Correct |
6 ms |
5716 KB |
Output is correct |
29 |
Correct |
24 ms |
12688 KB |
Output is correct |
30 |
Correct |
37 ms |
15364 KB |
Output is correct |
31 |
Correct |
76 ms |
21460 KB |
Output is correct |
32 |
Correct |
77 ms |
21480 KB |
Output is correct |
33 |
Correct |
65 ms |
21476 KB |
Output is correct |
34 |
Correct |
62 ms |
21460 KB |
Output is correct |
35 |
Correct |
63 ms |
21460 KB |
Output is correct |
36 |
Correct |
74 ms |
21448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
852 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
2260 KB |
Output is correct |
7 |
Correct |
2 ms |
2900 KB |
Output is correct |
8 |
Correct |
3 ms |
3796 KB |
Output is correct |
9 |
Correct |
3 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
3796 KB |
Output is correct |
11 |
Correct |
3 ms |
3796 KB |
Output is correct |
12 |
Correct |
3 ms |
3796 KB |
Output is correct |
13 |
Correct |
3 ms |
3796 KB |
Output is correct |
14 |
Correct |
4 ms |
4232 KB |
Output is correct |
15 |
Correct |
6 ms |
5716 KB |
Output is correct |
16 |
Correct |
29 ms |
12628 KB |
Output is correct |
17 |
Correct |
38 ms |
15316 KB |
Output is correct |
18 |
Correct |
63 ms |
21476 KB |
Output is correct |
19 |
Correct |
70 ms |
21480 KB |
Output is correct |
20 |
Correct |
71 ms |
21488 KB |
Output is correct |
21 |
Correct |
63 ms |
21480 KB |
Output is correct |
22 |
Correct |
64 ms |
21476 KB |
Output is correct |
23 |
Correct |
77 ms |
21460 KB |
Output is correct |
24 |
Correct |
69 ms |
21844 KB |
Output is correct |
25 |
Incorrect |
116 ms |
28084 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
852 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
596 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
2 ms |
2260 KB |
Output is correct |
7 |
Correct |
2 ms |
2888 KB |
Output is correct |
8 |
Correct |
5 ms |
3796 KB |
Output is correct |
9 |
Correct |
4 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
3796 KB |
Output is correct |
11 |
Correct |
3 ms |
3796 KB |
Output is correct |
12 |
Correct |
4 ms |
3796 KB |
Output is correct |
13 |
Correct |
3 ms |
3796 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
596 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
1 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
2 ms |
2884 KB |
Output is correct |
21 |
Correct |
3 ms |
3796 KB |
Output is correct |
22 |
Correct |
4 ms |
3796 KB |
Output is correct |
23 |
Correct |
3 ms |
3796 KB |
Output is correct |
24 |
Correct |
3 ms |
3796 KB |
Output is correct |
25 |
Correct |
3 ms |
3788 KB |
Output is correct |
26 |
Correct |
3 ms |
3796 KB |
Output is correct |
27 |
Runtime error |
2 ms |
964 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
852 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
596 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
2 ms |
2260 KB |
Output is correct |
7 |
Correct |
2 ms |
2888 KB |
Output is correct |
8 |
Correct |
3 ms |
3796 KB |
Output is correct |
9 |
Correct |
3 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
3796 KB |
Output is correct |
11 |
Correct |
3 ms |
3796 KB |
Output is correct |
12 |
Correct |
3 ms |
3796 KB |
Output is correct |
13 |
Correct |
3 ms |
3796 KB |
Output is correct |
14 |
Runtime error |
2 ms |
980 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |