#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#define int ll
const int N=2020,lg=50;
int n,t,ans,L,R,a[N],dp[N][N],pd[N];
bool check1(int mask){
f(i,0,N) f(j,0,N) dp[i][j]=0;
dp[0][0]=1;
f(i,1,n+1){
f(j,1,i+1){
f(k,0,i){
if(((a[i]-a[k])|mask)==mask){
dp[i][j]|=dp[k][j-1];
}
}
}
}
f(i,L,R+1) if(dp[n][i]) return 1;
return 0;
}
bool check2(int mask){
pd[0]=0;
f(i,1,n+1){
pd[i]=n+1;
f(j,0,i){
if(((a[i]-a[j])|mask)==mask){
minm(pd[i],pd[j]+1);
}
}
}
return pd[n]<=R;
}
main(){
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
cin>>n>>L>>R;
f(i,1,n+1){
cin>>a[i];
a[i]+=a[i-1];
}
ans=(1ll<<lg)-1;
f_(i,lg-1,0){
if(n<=100 && check1(ans^(1ll<<i))){
ans^=(1ll<<i);
}
if(100<n && check2(ans^(1ll<<i))){
ans^=(1ll<<i);
}
}
cout<<ans;
}
Compilation message
sculpture.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
56 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
32240 KB |
Output is correct |
2 |
Correct |
179 ms |
32244 KB |
Output is correct |
3 |
Correct |
177 ms |
32136 KB |
Output is correct |
4 |
Correct |
176 ms |
32240 KB |
Output is correct |
5 |
Correct |
175 ms |
32240 KB |
Output is correct |
6 |
Correct |
179 ms |
32256 KB |
Output is correct |
7 |
Correct |
177 ms |
32244 KB |
Output is correct |
8 |
Correct |
174 ms |
32172 KB |
Output is correct |
9 |
Correct |
177 ms |
32204 KB |
Output is correct |
10 |
Correct |
181 ms |
32240 KB |
Output is correct |
11 |
Correct |
175 ms |
32204 KB |
Output is correct |
12 |
Correct |
177 ms |
32244 KB |
Output is correct |
13 |
Correct |
185 ms |
32244 KB |
Output is correct |
14 |
Correct |
176 ms |
32240 KB |
Output is correct |
15 |
Correct |
174 ms |
32204 KB |
Output is correct |
16 |
Correct |
175 ms |
32148 KB |
Output is correct |
17 |
Correct |
174 ms |
32204 KB |
Output is correct |
18 |
Correct |
175 ms |
32204 KB |
Output is correct |
19 |
Correct |
176 ms |
32204 KB |
Output is correct |
20 |
Correct |
177 ms |
32248 KB |
Output is correct |
21 |
Correct |
178 ms |
32204 KB |
Output is correct |
22 |
Correct |
175 ms |
32240 KB |
Output is correct |
23 |
Correct |
174 ms |
32204 KB |
Output is correct |
24 |
Correct |
180 ms |
32240 KB |
Output is correct |
25 |
Correct |
180 ms |
32240 KB |
Output is correct |
26 |
Correct |
180 ms |
32240 KB |
Output is correct |
27 |
Correct |
176 ms |
32244 KB |
Output is correct |
28 |
Correct |
180 ms |
32244 KB |
Output is correct |
29 |
Correct |
177 ms |
32204 KB |
Output is correct |
30 |
Correct |
183 ms |
32244 KB |
Output is correct |
31 |
Correct |
177 ms |
32204 KB |
Output is correct |
32 |
Correct |
178 ms |
32248 KB |
Output is correct |
33 |
Correct |
177 ms |
32244 KB |
Output is correct |
34 |
Correct |
181 ms |
32252 KB |
Output is correct |
35 |
Correct |
183 ms |
32328 KB |
Output is correct |
36 |
Correct |
178 ms |
32244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
32240 KB |
Output is correct |
2 |
Correct |
177 ms |
32240 KB |
Output is correct |
3 |
Correct |
183 ms |
32204 KB |
Output is correct |
4 |
Correct |
179 ms |
32240 KB |
Output is correct |
5 |
Correct |
180 ms |
32244 KB |
Output is correct |
6 |
Correct |
180 ms |
32252 KB |
Output is correct |
7 |
Correct |
176 ms |
32244 KB |
Output is correct |
8 |
Correct |
174 ms |
32244 KB |
Output is correct |
9 |
Correct |
179 ms |
32204 KB |
Output is correct |
10 |
Correct |
177 ms |
32324 KB |
Output is correct |
11 |
Correct |
179 ms |
32204 KB |
Output is correct |
12 |
Correct |
185 ms |
32252 KB |
Output is correct |
13 |
Correct |
178 ms |
32324 KB |
Output is correct |
14 |
Correct |
176 ms |
32204 KB |
Output is correct |
15 |
Correct |
175 ms |
32204 KB |
Output is correct |
16 |
Correct |
176 ms |
32204 KB |
Output is correct |
17 |
Correct |
179 ms |
32244 KB |
Output is correct |
18 |
Correct |
176 ms |
32244 KB |
Output is correct |
19 |
Correct |
174 ms |
32244 KB |
Output is correct |
20 |
Correct |
175 ms |
32244 KB |
Output is correct |
21 |
Correct |
179 ms |
32248 KB |
Output is correct |
22 |
Correct |
182 ms |
32244 KB |
Output is correct |
23 |
Correct |
179 ms |
32204 KB |
Output is correct |
24 |
Correct |
183 ms |
32304 KB |
Output is correct |
25 |
Correct |
175 ms |
32244 KB |
Output is correct |
26 |
Correct |
175 ms |
32244 KB |
Output is correct |
27 |
Correct |
201 ms |
32244 KB |
Output is correct |
28 |
Correct |
178 ms |
32248 KB |
Output is correct |
29 |
Correct |
178 ms |
32244 KB |
Output is correct |
30 |
Correct |
177 ms |
32244 KB |
Output is correct |
31 |
Correct |
181 ms |
32204 KB |
Output is correct |
32 |
Correct |
179 ms |
32244 KB |
Output is correct |
33 |
Correct |
184 ms |
32244 KB |
Output is correct |
34 |
Correct |
177 ms |
32240 KB |
Output is correct |
35 |
Correct |
183 ms |
32244 KB |
Output is correct |
36 |
Correct |
179 ms |
32248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
32240 KB |
Output is correct |
2 |
Correct |
194 ms |
32240 KB |
Output is correct |
3 |
Correct |
181 ms |
32248 KB |
Output is correct |
4 |
Correct |
180 ms |
32240 KB |
Output is correct |
5 |
Correct |
180 ms |
32244 KB |
Output is correct |
6 |
Correct |
176 ms |
32240 KB |
Output is correct |
7 |
Correct |
178 ms |
32192 KB |
Output is correct |
8 |
Correct |
175 ms |
32240 KB |
Output is correct |
9 |
Correct |
182 ms |
32204 KB |
Output is correct |
10 |
Correct |
178 ms |
32244 KB |
Output is correct |
11 |
Correct |
178 ms |
32204 KB |
Output is correct |
12 |
Correct |
179 ms |
32244 KB |
Output is correct |
13 |
Correct |
178 ms |
32324 KB |
Output is correct |
14 |
Correct |
174 ms |
32240 KB |
Output is correct |
15 |
Correct |
176 ms |
32204 KB |
Output is correct |
16 |
Correct |
180 ms |
32244 KB |
Output is correct |
17 |
Correct |
178 ms |
32240 KB |
Output is correct |
18 |
Correct |
196 ms |
32244 KB |
Output is correct |
19 |
Correct |
180 ms |
32244 KB |
Output is correct |
20 |
Correct |
181 ms |
32256 KB |
Output is correct |
21 |
Correct |
177 ms |
32204 KB |
Output is correct |
22 |
Correct |
179 ms |
32244 KB |
Output is correct |
23 |
Correct |
189 ms |
32252 KB |
Output is correct |
24 |
Correct |
178 ms |
32244 KB |
Output is correct |
25 |
Correct |
181 ms |
32204 KB |
Output is correct |
26 |
Correct |
194 ms |
32244 KB |
Output is correct |
27 |
Correct |
197 ms |
32204 KB |
Output is correct |
28 |
Correct |
213 ms |
32256 KB |
Output is correct |
29 |
Correct |
203 ms |
32240 KB |
Output is correct |
30 |
Correct |
208 ms |
32248 KB |
Output is correct |
31 |
Correct |
204 ms |
32204 KB |
Output is correct |
32 |
Correct |
206 ms |
32204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
32248 KB |
Output is correct |
2 |
Correct |
192 ms |
32240 KB |
Output is correct |
3 |
Correct |
175 ms |
32244 KB |
Output is correct |
4 |
Correct |
174 ms |
32244 KB |
Output is correct |
5 |
Correct |
183 ms |
32204 KB |
Output is correct |
6 |
Correct |
175 ms |
32204 KB |
Output is correct |
7 |
Correct |
173 ms |
32244 KB |
Output is correct |
8 |
Correct |
192 ms |
32244 KB |
Output is correct |
9 |
Correct |
182 ms |
32204 KB |
Output is correct |
10 |
Correct |
177 ms |
32176 KB |
Output is correct |
11 |
Correct |
179 ms |
32204 KB |
Output is correct |
12 |
Correct |
182 ms |
32248 KB |
Output is correct |
13 |
Correct |
184 ms |
32204 KB |
Output is correct |
14 |
Correct |
186 ms |
32204 KB |
Output is correct |
15 |
Correct |
181 ms |
32176 KB |
Output is correct |
16 |
Correct |
181 ms |
32240 KB |
Output is correct |
17 |
Correct |
181 ms |
32204 KB |
Output is correct |
18 |
Correct |
183 ms |
32204 KB |
Output is correct |
19 |
Correct |
198 ms |
32240 KB |
Output is correct |
20 |
Correct |
178 ms |
32188 KB |
Output is correct |
21 |
Correct |
177 ms |
32244 KB |
Output is correct |
22 |
Correct |
177 ms |
32244 KB |
Output is correct |
23 |
Correct |
177 ms |
32324 KB |
Output is correct |
24 |
Correct |
176 ms |
32244 KB |
Output is correct |
25 |
Correct |
175 ms |
32204 KB |
Output is correct |
26 |
Correct |
174 ms |
32244 KB |
Output is correct |
27 |
Correct |
176 ms |
32252 KB |
Output is correct |
28 |
Correct |
174 ms |
32244 KB |
Output is correct |
29 |
Correct |
176 ms |
32204 KB |
Output is correct |
30 |
Correct |
203 ms |
32244 KB |
Output is correct |
31 |
Correct |
176 ms |
32204 KB |
Output is correct |
32 |
Correct |
174 ms |
32248 KB |
Output is correct |
33 |
Correct |
178 ms |
32324 KB |
Output is correct |
34 |
Correct |
176 ms |
32240 KB |
Output is correct |
35 |
Correct |
176 ms |
32232 KB |
Output is correct |
36 |
Correct |
174 ms |
32244 KB |
Output is correct |
37 |
Correct |
193 ms |
32324 KB |
Output is correct |
38 |
Correct |
176 ms |
32244 KB |
Output is correct |
39 |
Correct |
176 ms |
32204 KB |
Output is correct |
40 |
Correct |
177 ms |
32256 KB |
Output is correct |
41 |
Correct |
179 ms |
32332 KB |
Output is correct |
42 |
Correct |
177 ms |
32228 KB |
Output is correct |
43 |
Correct |
180 ms |
32240 KB |
Output is correct |
44 |
Correct |
179 ms |
32244 KB |
Output is correct |
45 |
Correct |
179 ms |
32204 KB |
Output is correct |
46 |
Correct |
180 ms |
32244 KB |
Output is correct |
47 |
Correct |
183 ms |
32244 KB |
Output is correct |
48 |
Correct |
192 ms |
32244 KB |
Output is correct |
49 |
Correct |
206 ms |
32204 KB |
Output is correct |
50 |
Correct |
196 ms |
32252 KB |
Output is correct |
51 |
Correct |
212 ms |
32256 KB |
Output is correct |
52 |
Correct |
226 ms |
32204 KB |
Output is correct |
53 |
Correct |
206 ms |
32244 KB |
Output is correct |
54 |
Correct |
226 ms |
32268 KB |
Output is correct |
55 |
Correct |
206 ms |
32248 KB |
Output is correct |
56 |
Correct |
180 ms |
32256 KB |
Output is correct |
57 |
Correct |
184 ms |
32204 KB |
Output is correct |
58 |
Correct |
190 ms |
32248 KB |
Output is correct |
59 |
Correct |
195 ms |
32204 KB |
Output is correct |
60 |
Correct |
198 ms |
32252 KB |
Output is correct |
61 |
Correct |
194 ms |
32248 KB |
Output is correct |
62 |
Correct |
197 ms |
32260 KB |
Output is correct |
63 |
Correct |
204 ms |
32204 KB |
Output is correct |
64 |
Correct |
207 ms |
32248 KB |
Output is correct |
65 |
Correct |
178 ms |
32244 KB |
Output is correct |
66 |
Correct |
181 ms |
32240 KB |
Output is correct |
67 |
Correct |
198 ms |
32180 KB |
Output is correct |
68 |
Correct |
209 ms |
32248 KB |
Output is correct |
69 |
Correct |
198 ms |
32244 KB |
Output is correct |
70 |
Correct |
202 ms |
32244 KB |
Output is correct |
71 |
Correct |
208 ms |
32252 KB |
Output is correct |
72 |
Correct |
197 ms |
32204 KB |
Output is correct |
73 |
Correct |
203 ms |
32248 KB |
Output is correct |
74 |
Correct |
197 ms |
32264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
32244 KB |
Output is correct |
2 |
Correct |
173 ms |
32248 KB |
Output is correct |
3 |
Correct |
178 ms |
32240 KB |
Output is correct |
4 |
Correct |
174 ms |
32240 KB |
Output is correct |
5 |
Correct |
176 ms |
32236 KB |
Output is correct |
6 |
Correct |
175 ms |
32204 KB |
Output is correct |
7 |
Correct |
178 ms |
32252 KB |
Output is correct |
8 |
Correct |
174 ms |
32236 KB |
Output is correct |
9 |
Correct |
175 ms |
32240 KB |
Output is correct |
10 |
Correct |
178 ms |
32236 KB |
Output is correct |
11 |
Correct |
174 ms |
32204 KB |
Output is correct |
12 |
Correct |
174 ms |
32160 KB |
Output is correct |
13 |
Correct |
175 ms |
32204 KB |
Output is correct |
14 |
Correct |
184 ms |
32236 KB |
Output is correct |
15 |
Correct |
178 ms |
32204 KB |
Output is correct |
16 |
Correct |
173 ms |
32248 KB |
Output is correct |
17 |
Correct |
176 ms |
32204 KB |
Output is correct |
18 |
Correct |
176 ms |
32236 KB |
Output is correct |
19 |
Correct |
178 ms |
32248 KB |
Output is correct |
20 |
Correct |
174 ms |
32240 KB |
Output is correct |
21 |
Correct |
175 ms |
32324 KB |
Output is correct |
22 |
Correct |
177 ms |
32252 KB |
Output is correct |
23 |
Correct |
175 ms |
32204 KB |
Output is correct |
24 |
Correct |
175 ms |
32236 KB |
Output is correct |
25 |
Correct |
178 ms |
32324 KB |
Output is correct |
26 |
Correct |
176 ms |
32240 KB |
Output is correct |
27 |
Correct |
178 ms |
32204 KB |
Output is correct |
28 |
Correct |
180 ms |
32248 KB |
Output is correct |
29 |
Correct |
180 ms |
32236 KB |
Output is correct |
30 |
Correct |
180 ms |
32240 KB |
Output is correct |
31 |
Correct |
186 ms |
32240 KB |
Output is correct |
32 |
Correct |
188 ms |
32240 KB |
Output is correct |
33 |
Correct |
191 ms |
32240 KB |
Output is correct |
34 |
Correct |
179 ms |
32256 KB |
Output is correct |
35 |
Correct |
185 ms |
32204 KB |
Output is correct |
36 |
Correct |
194 ms |
32256 KB |
Output is correct |
37 |
Correct |
197 ms |
32204 KB |
Output is correct |
38 |
Correct |
203 ms |
32240 KB |
Output is correct |
39 |
Correct |
208 ms |
32328 KB |
Output is correct |
40 |
Correct |
209 ms |
32228 KB |
Output is correct |
41 |
Correct |
208 ms |
32204 KB |
Output is correct |
42 |
Correct |
207 ms |
32240 KB |
Output is correct |
43 |
Correct |
186 ms |
32240 KB |
Output is correct |
44 |
Correct |
186 ms |
32204 KB |
Output is correct |
45 |
Correct |
190 ms |
32204 KB |
Output is correct |
46 |
Correct |
201 ms |
32324 KB |
Output is correct |
47 |
Correct |
198 ms |
32148 KB |
Output is correct |
48 |
Correct |
203 ms |
32248 KB |
Output is correct |
49 |
Correct |
198 ms |
32204 KB |
Output is correct |
50 |
Correct |
190 ms |
32244 KB |
Output is correct |
51 |
Correct |
1 ms |
332 KB |
Output is correct |
52 |
Correct |
12 ms |
332 KB |
Output is correct |
53 |
Correct |
20 ms |
328 KB |
Output is correct |
54 |
Correct |
38 ms |
332 KB |
Output is correct |
55 |
Correct |
35 ms |
336 KB |
Output is correct |
56 |
Correct |
146 ms |
356 KB |
Output is correct |
57 |
Correct |
137 ms |
352 KB |
Output is correct |
58 |
Correct |
124 ms |
360 KB |
Output is correct |
59 |
Correct |
123 ms |
360 KB |
Output is correct |
60 |
Correct |
138 ms |
332 KB |
Output is correct |
61 |
Correct |
1 ms |
332 KB |
Output is correct |
62 |
Correct |
22 ms |
332 KB |
Output is correct |
63 |
Correct |
37 ms |
332 KB |
Output is correct |
64 |
Correct |
36 ms |
336 KB |
Output is correct |
65 |
Correct |
65 ms |
344 KB |
Output is correct |
66 |
Correct |
107 ms |
356 KB |
Output is correct |
67 |
Correct |
147 ms |
368 KB |
Output is correct |
68 |
Correct |
141 ms |
360 KB |
Output is correct |
69 |
Correct |
141 ms |
356 KB |
Output is correct |