#include <bits/stdc++.h>
#define int long long
#define MAXN 2005
#define LN 45
#define INF 2000000000000000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
using namespace std;
typedef pair<int,int> pp;
int a[MAXN],n,l,r,sum[MAXN],ans=0,mustval=0;
bool dead [LN];
int lg[LN+2];
int dp5[MAXN];
bool dp[MAXN][MAXN];
bool checks (int sum){
sum=lg[LN]-1-sum;
//cout<<sum<<' '<<mustval<<'\n';
if ((sum&mustval) == mustval) return true;
return false;
}
main(){
ios::sync_with_stdio(false); cin.tie(0);
//freopen("inp.txt","r",stdin);
cin>>n>>l>>r;
int i,j,k,d;
for (i=1;i<=n;i++){
cin>>a[i];
}
lg[0]=1; for (i=1;i<=LN;i++) lg[i]=lg[i-1]*2;
sum[0]=0;
for (i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
if (l == 0){ // sub5
for (k=LN-1; k >=0; k--){
dead[k]=true; mustval+=lg[k];
dp5[0]=0; for(i=1;i<=n;i++) dp5[i]=INF;
for (i=0;i<=n;i++){
for (j=i+1;j<=n;j++){
if (checks(sum[j]-sum[i])){
dp5[j]=min(dp5[j],dp5[i]+1);
}
}
}
//cout<<k<<' '<<dp[n]<<'\n';
if (dp5[n] > r){
dead[k]=false;
mustval-=lg[k];
ans+=lg[k];
}
else{
;
}
}
cout<<ans; return 0;
}
for (k=LN-1;k >=0 ;k--){
dead[k]=true; mustval += lg[k];
for (i=0;i<=n;i++){
for (j=0;j<=n;j++) dp[i][j]=false;
}
dp[0][0]=true;
for (i=0;i<=n;i++){
for (j=0;j<n;j++){
for (d=i+1;d<=n;d++){
if (dp[i][j]==true && checks(sum[d]-sum[i])){
dp[d][j+1]=true;
}
}
}
}
bool gg=false;
for (i=l;i<=r;i++){
if (dp[n][i]==true) gg=true;
}
if (!gg){
//cout<<k<<'\n';
dead[k]=false; mustval-=lg[k]; ans+=lg[k];
}
}
cout<<ans;
return 0;
}
/* Beware of Constants and Constraints. Check again.
If graph -> da do thi
If Multitest -> eye-check init() function
*/
Compilation message
sculpture.cpp:27:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
380 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
388 KB |
Output is correct |
30 |
Correct |
2 ms |
376 KB |
Output is correct |
31 |
Correct |
3 ms |
376 KB |
Output is correct |
32 |
Correct |
3 ms |
376 KB |
Output is correct |
33 |
Correct |
3 ms |
376 KB |
Output is correct |
34 |
Correct |
2 ms |
376 KB |
Output is correct |
35 |
Correct |
2 ms |
376 KB |
Output is correct |
36 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
3 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
380 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Correct |
3 ms |
376 KB |
Output is correct |
29 |
Correct |
6 ms |
376 KB |
Output is correct |
30 |
Correct |
6 ms |
504 KB |
Output is correct |
31 |
Correct |
7 ms |
504 KB |
Output is correct |
32 |
Correct |
7 ms |
376 KB |
Output is correct |
33 |
Correct |
7 ms |
376 KB |
Output is correct |
34 |
Correct |
7 ms |
504 KB |
Output is correct |
35 |
Correct |
7 ms |
504 KB |
Output is correct |
36 |
Correct |
7 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
7 ms |
504 KB |
Output is correct |
19 |
Correct |
7 ms |
376 KB |
Output is correct |
20 |
Correct |
7 ms |
376 KB |
Output is correct |
21 |
Correct |
7 ms |
428 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
7 ms |
376 KB |
Output is correct |
24 |
Correct |
7 ms |
376 KB |
Output is correct |
25 |
Correct |
12 ms |
504 KB |
Output is correct |
26 |
Correct |
18 ms |
480 KB |
Output is correct |
27 |
Correct |
26 ms |
504 KB |
Output is correct |
28 |
Correct |
34 ms |
588 KB |
Output is correct |
29 |
Correct |
34 ms |
636 KB |
Output is correct |
30 |
Correct |
34 ms |
592 KB |
Output is correct |
31 |
Correct |
35 ms |
504 KB |
Output is correct |
32 |
Correct |
33 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
292 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
372 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
2 ms |
376 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
2 ms |
376 KB |
Output is correct |
35 |
Correct |
2 ms |
376 KB |
Output is correct |
36 |
Correct |
3 ms |
376 KB |
Output is correct |
37 |
Correct |
3 ms |
376 KB |
Output is correct |
38 |
Correct |
3 ms |
360 KB |
Output is correct |
39 |
Correct |
4 ms |
376 KB |
Output is correct |
40 |
Correct |
5 ms |
472 KB |
Output is correct |
41 |
Correct |
7 ms |
376 KB |
Output is correct |
42 |
Correct |
7 ms |
376 KB |
Output is correct |
43 |
Correct |
7 ms |
376 KB |
Output is correct |
44 |
Correct |
7 ms |
376 KB |
Output is correct |
45 |
Correct |
7 ms |
376 KB |
Output is correct |
46 |
Correct |
6 ms |
376 KB |
Output is correct |
47 |
Correct |
7 ms |
376 KB |
Output is correct |
48 |
Correct |
11 ms |
504 KB |
Output is correct |
49 |
Correct |
18 ms |
504 KB |
Output is correct |
50 |
Correct |
26 ms |
504 KB |
Output is correct |
51 |
Correct |
33 ms |
632 KB |
Output is correct |
52 |
Correct |
33 ms |
504 KB |
Output is correct |
53 |
Correct |
34 ms |
632 KB |
Output is correct |
54 |
Correct |
33 ms |
504 KB |
Output is correct |
55 |
Correct |
33 ms |
504 KB |
Output is correct |
56 |
Correct |
6 ms |
380 KB |
Output is correct |
57 |
Correct |
16 ms |
504 KB |
Output is correct |
58 |
Correct |
22 ms |
504 KB |
Output is correct |
59 |
Correct |
29 ms |
504 KB |
Output is correct |
60 |
Correct |
28 ms |
504 KB |
Output is correct |
61 |
Correct |
29 ms |
504 KB |
Output is correct |
62 |
Correct |
31 ms |
632 KB |
Output is correct |
63 |
Correct |
29 ms |
504 KB |
Output is correct |
64 |
Correct |
26 ms |
504 KB |
Output is correct |
65 |
Correct |
6 ms |
376 KB |
Output is correct |
66 |
Correct |
10 ms |
504 KB |
Output is correct |
67 |
Correct |
16 ms |
548 KB |
Output is correct |
68 |
Correct |
24 ms |
632 KB |
Output is correct |
69 |
Correct |
29 ms |
504 KB |
Output is correct |
70 |
Correct |
29 ms |
504 KB |
Output is correct |
71 |
Correct |
29 ms |
504 KB |
Output is correct |
72 |
Correct |
30 ms |
632 KB |
Output is correct |
73 |
Correct |
29 ms |
504 KB |
Output is correct |
74 |
Correct |
31 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
380 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
420 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
376 KB |
Output is correct |
26 |
Correct |
4 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
504 KB |
Output is correct |
30 |
Correct |
7 ms |
376 KB |
Output is correct |
31 |
Correct |
7 ms |
376 KB |
Output is correct |
32 |
Correct |
7 ms |
376 KB |
Output is correct |
33 |
Correct |
7 ms |
380 KB |
Output is correct |
34 |
Correct |
7 ms |
504 KB |
Output is correct |
35 |
Correct |
11 ms |
504 KB |
Output is correct |
36 |
Correct |
18 ms |
548 KB |
Output is correct |
37 |
Correct |
27 ms |
572 KB |
Output is correct |
38 |
Correct |
33 ms |
504 KB |
Output is correct |
39 |
Correct |
34 ms |
504 KB |
Output is correct |
40 |
Correct |
35 ms |
504 KB |
Output is correct |
41 |
Correct |
35 ms |
504 KB |
Output is correct |
42 |
Correct |
33 ms |
504 KB |
Output is correct |
43 |
Correct |
6 ms |
380 KB |
Output is correct |
44 |
Correct |
16 ms |
504 KB |
Output is correct |
45 |
Correct |
23 ms |
504 KB |
Output is correct |
46 |
Correct |
29 ms |
504 KB |
Output is correct |
47 |
Correct |
29 ms |
504 KB |
Output is correct |
48 |
Correct |
29 ms |
504 KB |
Output is correct |
49 |
Correct |
29 ms |
504 KB |
Output is correct |
50 |
Correct |
32 ms |
504 KB |
Output is correct |
51 |
Correct |
30 ms |
596 KB |
Output is correct |
52 |
Execution timed out |
1075 ms |
1528 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |