#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define se second
#define fi first
#define pb push_back
#define wek puts("wekwek")
#define wik puts("-------")
const int nax = 2e3;
const ll INF = (1ll<<42)-1;
int n, a, b;
int dp[nax+5][nax+5];
ll p[nax+5];
ll sum (int l, int r) {
return p[r] - p[l-1];
}
int f(int grup, int idx, ll x) {
if(grup > b) return 0;
if(idx == n+1) {
return (a <= grup && grup <= b);
}
int &ret = dp[grup][idx];
if(~ret) return ret;
ret = 0;
for(int j=idx; j<=n; j++) {
if((x | sum(idx,j)) == x) {
ret |= f(grup+1, j+1, x);
}
}
//cout << grup << " " << idx << " " << ret << endl;
return ret;
}
signed main () {
scanf("%d %d %d", &n, &a, &b);
for(int i=1; i<=n; i++) {
scanf("%lld", &p[i]);
p[i] += p[i-1];
//cout << i << " " << p[i] << endl;
}
ll lo = 0, hi = INF;
ll ans = hi;
while(lo <= hi) {
ll mid = (lo+hi)/2;
memset(dp, -1, sizeof dp);
//cout << bitset<64> (mid) << endl;
if(f(0, 1, mid)) {
ans = mid;
hi = mid-1;
} else {
lo = mid+1;
}
}
printf("%lld", ans);
}
/*
*/
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | scanf("%d %d %d", &n, &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | scanf("%lld", &p[i]);
| ~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
16012 KB |
Output is correct |
2 |
Correct |
71 ms |
16012 KB |
Output is correct |
3 |
Correct |
75 ms |
16012 KB |
Output is correct |
4 |
Correct |
72 ms |
16008 KB |
Output is correct |
5 |
Correct |
73 ms |
16012 KB |
Output is correct |
6 |
Correct |
71 ms |
16008 KB |
Output is correct |
7 |
Correct |
70 ms |
16008 KB |
Output is correct |
8 |
Correct |
72 ms |
15948 KB |
Output is correct |
9 |
Correct |
77 ms |
16068 KB |
Output is correct |
10 |
Correct |
69 ms |
16008 KB |
Output is correct |
11 |
Correct |
72 ms |
16016 KB |
Output is correct |
12 |
Correct |
72 ms |
15948 KB |
Output is correct |
13 |
Correct |
71 ms |
15948 KB |
Output is correct |
14 |
Correct |
71 ms |
15948 KB |
Output is correct |
15 |
Correct |
69 ms |
16012 KB |
Output is correct |
16 |
Correct |
69 ms |
16008 KB |
Output is correct |
17 |
Correct |
70 ms |
15948 KB |
Output is correct |
18 |
Correct |
73 ms |
16020 KB |
Output is correct |
19 |
Correct |
74 ms |
16020 KB |
Output is correct |
20 |
Correct |
73 ms |
15912 KB |
Output is correct |
21 |
Correct |
76 ms |
16016 KB |
Output is correct |
22 |
Correct |
74 ms |
16012 KB |
Output is correct |
23 |
Correct |
78 ms |
16008 KB |
Output is correct |
24 |
Correct |
71 ms |
15948 KB |
Output is correct |
25 |
Correct |
73 ms |
16068 KB |
Output is correct |
26 |
Correct |
72 ms |
16016 KB |
Output is correct |
27 |
Correct |
70 ms |
16076 KB |
Output is correct |
28 |
Correct |
72 ms |
16012 KB |
Output is correct |
29 |
Correct |
83 ms |
15892 KB |
Output is correct |
30 |
Correct |
73 ms |
15948 KB |
Output is correct |
31 |
Correct |
71 ms |
15948 KB |
Output is correct |
32 |
Correct |
72 ms |
15948 KB |
Output is correct |
33 |
Correct |
71 ms |
16012 KB |
Output is correct |
34 |
Correct |
71 ms |
16008 KB |
Output is correct |
35 |
Correct |
73 ms |
16036 KB |
Output is correct |
36 |
Correct |
72 ms |
16020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
15948 KB |
Output is correct |
2 |
Correct |
69 ms |
16012 KB |
Output is correct |
3 |
Correct |
72 ms |
15920 KB |
Output is correct |
4 |
Correct |
72 ms |
15948 KB |
Output is correct |
5 |
Correct |
72 ms |
15948 KB |
Output is correct |
6 |
Correct |
72 ms |
16008 KB |
Output is correct |
7 |
Correct |
73 ms |
15948 KB |
Output is correct |
8 |
Correct |
73 ms |
15908 KB |
Output is correct |
9 |
Correct |
71 ms |
15948 KB |
Output is correct |
10 |
Correct |
82 ms |
16012 KB |
Output is correct |
11 |
Correct |
72 ms |
15948 KB |
Output is correct |
12 |
Correct |
78 ms |
16072 KB |
Output is correct |
13 |
Correct |
72 ms |
15948 KB |
Output is correct |
14 |
Correct |
75 ms |
16012 KB |
Output is correct |
15 |
Correct |
73 ms |
16008 KB |
Output is correct |
16 |
Correct |
70 ms |
16020 KB |
Output is correct |
17 |
Correct |
72 ms |
16012 KB |
Output is correct |
18 |
Correct |
80 ms |
15916 KB |
Output is correct |
19 |
Correct |
76 ms |
15912 KB |
Output is correct |
20 |
Correct |
76 ms |
16008 KB |
Output is correct |
21 |
Correct |
71 ms |
15948 KB |
Output is correct |
22 |
Correct |
72 ms |
16008 KB |
Output is correct |
23 |
Correct |
72 ms |
15920 KB |
Output is correct |
24 |
Correct |
71 ms |
15948 KB |
Output is correct |
25 |
Correct |
72 ms |
15948 KB |
Output is correct |
26 |
Correct |
73 ms |
15948 KB |
Output is correct |
27 |
Correct |
73 ms |
16012 KB |
Output is correct |
28 |
Correct |
76 ms |
16016 KB |
Output is correct |
29 |
Correct |
72 ms |
16020 KB |
Output is correct |
30 |
Correct |
75 ms |
15908 KB |
Output is correct |
31 |
Correct |
75 ms |
16020 KB |
Output is correct |
32 |
Correct |
73 ms |
16040 KB |
Output is correct |
33 |
Correct |
72 ms |
16012 KB |
Output is correct |
34 |
Correct |
76 ms |
16020 KB |
Output is correct |
35 |
Correct |
73 ms |
15948 KB |
Output is correct |
36 |
Correct |
75 ms |
15948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
16004 KB |
Output is correct |
2 |
Correct |
72 ms |
16012 KB |
Output is correct |
3 |
Correct |
71 ms |
16008 KB |
Output is correct |
4 |
Correct |
73 ms |
16012 KB |
Output is correct |
5 |
Correct |
71 ms |
15920 KB |
Output is correct |
6 |
Correct |
72 ms |
16068 KB |
Output is correct |
7 |
Correct |
71 ms |
15948 KB |
Output is correct |
8 |
Correct |
72 ms |
15948 KB |
Output is correct |
9 |
Correct |
71 ms |
16008 KB |
Output is correct |
10 |
Correct |
73 ms |
15948 KB |
Output is correct |
11 |
Correct |
73 ms |
15908 KB |
Output is correct |
12 |
Correct |
81 ms |
15916 KB |
Output is correct |
13 |
Correct |
71 ms |
15948 KB |
Output is correct |
14 |
Correct |
72 ms |
16016 KB |
Output is correct |
15 |
Correct |
74 ms |
16024 KB |
Output is correct |
16 |
Correct |
71 ms |
16008 KB |
Output is correct |
17 |
Correct |
74 ms |
16020 KB |
Output is correct |
18 |
Correct |
77 ms |
16008 KB |
Output is correct |
19 |
Correct |
74 ms |
15948 KB |
Output is correct |
20 |
Correct |
72 ms |
15948 KB |
Output is correct |
21 |
Correct |
82 ms |
16008 KB |
Output is correct |
22 |
Correct |
78 ms |
16012 KB |
Output is correct |
23 |
Correct |
72 ms |
16012 KB |
Output is correct |
24 |
Correct |
73 ms |
16024 KB |
Output is correct |
25 |
Correct |
74 ms |
16008 KB |
Output is correct |
26 |
Correct |
82 ms |
15948 KB |
Output is correct |
27 |
Correct |
91 ms |
16008 KB |
Output is correct |
28 |
Correct |
102 ms |
16016 KB |
Output is correct |
29 |
Correct |
102 ms |
16016 KB |
Output is correct |
30 |
Correct |
77 ms |
16016 KB |
Output is correct |
31 |
Correct |
100 ms |
15948 KB |
Output is correct |
32 |
Correct |
100 ms |
16012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
16000 KB |
Output is correct |
2 |
Correct |
71 ms |
16012 KB |
Output is correct |
3 |
Correct |
75 ms |
16008 KB |
Output is correct |
4 |
Correct |
71 ms |
15948 KB |
Output is correct |
5 |
Correct |
71 ms |
15948 KB |
Output is correct |
6 |
Correct |
71 ms |
15948 KB |
Output is correct |
7 |
Correct |
71 ms |
15892 KB |
Output is correct |
8 |
Correct |
78 ms |
16024 KB |
Output is correct |
9 |
Correct |
75 ms |
15948 KB |
Output is correct |
10 |
Correct |
71 ms |
16036 KB |
Output is correct |
11 |
Correct |
71 ms |
15912 KB |
Output is correct |
12 |
Correct |
73 ms |
15948 KB |
Output is correct |
13 |
Correct |
71 ms |
16012 KB |
Output is correct |
14 |
Correct |
74 ms |
16016 KB |
Output is correct |
15 |
Correct |
71 ms |
16012 KB |
Output is correct |
16 |
Correct |
70 ms |
15948 KB |
Output is correct |
17 |
Correct |
75 ms |
15992 KB |
Output is correct |
18 |
Correct |
71 ms |
15948 KB |
Output is correct |
19 |
Correct |
71 ms |
16012 KB |
Output is correct |
20 |
Correct |
79 ms |
16012 KB |
Output is correct |
21 |
Correct |
87 ms |
16012 KB |
Output is correct |
22 |
Correct |
77 ms |
16024 KB |
Output is correct |
23 |
Correct |
72 ms |
15948 KB |
Output is correct |
24 |
Correct |
75 ms |
16076 KB |
Output is correct |
25 |
Correct |
76 ms |
15948 KB |
Output is correct |
26 |
Correct |
78 ms |
16028 KB |
Output is correct |
27 |
Correct |
74 ms |
16120 KB |
Output is correct |
28 |
Correct |
71 ms |
16056 KB |
Output is correct |
29 |
Correct |
71 ms |
16012 KB |
Output is correct |
30 |
Correct |
72 ms |
15948 KB |
Output is correct |
31 |
Correct |
72 ms |
16008 KB |
Output is correct |
32 |
Correct |
73 ms |
16008 KB |
Output is correct |
33 |
Correct |
72 ms |
15948 KB |
Output is correct |
34 |
Correct |
71 ms |
15948 KB |
Output is correct |
35 |
Correct |
71 ms |
15896 KB |
Output is correct |
36 |
Correct |
75 ms |
16012 KB |
Output is correct |
37 |
Correct |
72 ms |
15892 KB |
Output is correct |
38 |
Correct |
72 ms |
16016 KB |
Output is correct |
39 |
Correct |
72 ms |
16016 KB |
Output is correct |
40 |
Correct |
74 ms |
15940 KB |
Output is correct |
41 |
Correct |
74 ms |
15904 KB |
Output is correct |
42 |
Correct |
75 ms |
15948 KB |
Output is correct |
43 |
Correct |
73 ms |
15948 KB |
Output is correct |
44 |
Correct |
78 ms |
16024 KB |
Output is correct |
45 |
Correct |
78 ms |
16008 KB |
Output is correct |
46 |
Correct |
80 ms |
15948 KB |
Output is correct |
47 |
Correct |
75 ms |
16024 KB |
Output is correct |
48 |
Correct |
80 ms |
16016 KB |
Output is correct |
49 |
Correct |
84 ms |
16008 KB |
Output is correct |
50 |
Correct |
92 ms |
16008 KB |
Output is correct |
51 |
Correct |
103 ms |
16012 KB |
Output is correct |
52 |
Correct |
101 ms |
15916 KB |
Output is correct |
53 |
Correct |
81 ms |
16012 KB |
Output is correct |
54 |
Correct |
100 ms |
15916 KB |
Output is correct |
55 |
Correct |
103 ms |
16016 KB |
Output is correct |
56 |
Correct |
74 ms |
16036 KB |
Output is correct |
57 |
Correct |
74 ms |
15948 KB |
Output is correct |
58 |
Correct |
76 ms |
15912 KB |
Output is correct |
59 |
Correct |
80 ms |
16032 KB |
Output is correct |
60 |
Correct |
78 ms |
15948 KB |
Output is correct |
61 |
Correct |
71 ms |
15948 KB |
Output is correct |
62 |
Correct |
83 ms |
16016 KB |
Output is correct |
63 |
Correct |
86 ms |
16012 KB |
Output is correct |
64 |
Correct |
100 ms |
15924 KB |
Output is correct |
65 |
Correct |
72 ms |
15916 KB |
Output is correct |
66 |
Correct |
81 ms |
16068 KB |
Output is correct |
67 |
Correct |
76 ms |
16016 KB |
Output is correct |
68 |
Correct |
77 ms |
16012 KB |
Output is correct |
69 |
Correct |
79 ms |
16016 KB |
Output is correct |
70 |
Correct |
81 ms |
15948 KB |
Output is correct |
71 |
Correct |
78 ms |
16008 KB |
Output is correct |
72 |
Correct |
92 ms |
16012 KB |
Output is correct |
73 |
Correct |
84 ms |
16012 KB |
Output is correct |
74 |
Correct |
88 ms |
16012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
15948 KB |
Output is correct |
2 |
Correct |
72 ms |
15916 KB |
Output is correct |
3 |
Correct |
71 ms |
16012 KB |
Output is correct |
4 |
Correct |
74 ms |
16016 KB |
Output is correct |
5 |
Correct |
72 ms |
16016 KB |
Output is correct |
6 |
Correct |
70 ms |
15948 KB |
Output is correct |
7 |
Correct |
72 ms |
15948 KB |
Output is correct |
8 |
Correct |
72 ms |
16008 KB |
Output is correct |
9 |
Correct |
73 ms |
15924 KB |
Output is correct |
10 |
Correct |
71 ms |
16008 KB |
Output is correct |
11 |
Correct |
71 ms |
16016 KB |
Output is correct |
12 |
Correct |
71 ms |
16016 KB |
Output is correct |
13 |
Correct |
80 ms |
16016 KB |
Output is correct |
14 |
Correct |
76 ms |
16012 KB |
Output is correct |
15 |
Correct |
73 ms |
16008 KB |
Output is correct |
16 |
Correct |
71 ms |
15948 KB |
Output is correct |
17 |
Correct |
71 ms |
16012 KB |
Output is correct |
18 |
Correct |
79 ms |
16008 KB |
Output is correct |
19 |
Correct |
71 ms |
16012 KB |
Output is correct |
20 |
Correct |
73 ms |
16008 KB |
Output is correct |
21 |
Correct |
72 ms |
15948 KB |
Output is correct |
22 |
Correct |
73 ms |
15948 KB |
Output is correct |
23 |
Correct |
71 ms |
16012 KB |
Output is correct |
24 |
Correct |
73 ms |
16008 KB |
Output is correct |
25 |
Correct |
72 ms |
16076 KB |
Output is correct |
26 |
Correct |
72 ms |
16012 KB |
Output is correct |
27 |
Correct |
74 ms |
15916 KB |
Output is correct |
28 |
Correct |
77 ms |
16016 KB |
Output is correct |
29 |
Correct |
74 ms |
16020 KB |
Output is correct |
30 |
Correct |
73 ms |
16016 KB |
Output is correct |
31 |
Correct |
74 ms |
16012 KB |
Output is correct |
32 |
Correct |
75 ms |
16012 KB |
Output is correct |
33 |
Correct |
75 ms |
15948 KB |
Output is correct |
34 |
Correct |
73 ms |
16008 KB |
Output is correct |
35 |
Correct |
73 ms |
16020 KB |
Output is correct |
36 |
Correct |
80 ms |
15948 KB |
Output is correct |
37 |
Correct |
94 ms |
16016 KB |
Output is correct |
38 |
Correct |
112 ms |
16016 KB |
Output is correct |
39 |
Correct |
123 ms |
15948 KB |
Output is correct |
40 |
Correct |
72 ms |
16028 KB |
Output is correct |
41 |
Correct |
97 ms |
15948 KB |
Output is correct |
42 |
Correct |
100 ms |
15948 KB |
Output is correct |
43 |
Correct |
71 ms |
16012 KB |
Output is correct |
44 |
Correct |
74 ms |
15932 KB |
Output is correct |
45 |
Correct |
76 ms |
15948 KB |
Output is correct |
46 |
Correct |
78 ms |
16024 KB |
Output is correct |
47 |
Correct |
79 ms |
15948 KB |
Output is correct |
48 |
Correct |
72 ms |
16008 KB |
Output is correct |
49 |
Correct |
82 ms |
15940 KB |
Output is correct |
50 |
Correct |
83 ms |
16020 KB |
Output is correct |
51 |
Correct |
87 ms |
16012 KB |
Output is correct |
52 |
Correct |
588 ms |
16068 KB |
Output is correct |
53 |
Execution timed out |
1095 ms |
15980 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |