#include<bits/stdc++.h>
#define lf double
#define ll long long
#define cc pair<char,char>
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 1000000005
#define M 10000002
#define N 2005
#define LOG 40
#define magic 100
#define KOK 250
#define EPS 0.0025
#define pw(x) ((1ll)<<(x))
#define PI 3.1415926535
using namespace std;
int n,a,b;
int ar[N],mn[N];
bool dp[105][105];
vector<int> v[N];
bool ok(ll val) {
for(int i=1;i<=n;i++) {
v[i-1].clear();
mn[i]=inf;
ll sum=0;
for(int j=i-1;j>=0;j--) {
sum+=ar[j+1];
if((sum|val)==val) {
v[j].pb(i);
umin(mn[i],mn[j]+1);
}
}
}
if(a==1) {
return (mn[n]<=b);
}
memset(dp,0,sizeof(dp));
dp[0][0]=1;
for(int l=1;l<=n;l++) {
for(int i=0;i<=n;i++) {
if(dp[l-1][i]) {
for(int ind:v[i]) {
dp[l][ind]=1;
}
}
}
}
for(int i=a;i<=b;i++) if(dp[i][n]) return true;
return false;
}
int main() {
#if 0
freopen("input.txt","r",stdin);
#endif
scanf("%d %d %d",&n,&a,&b);
for(int i=1;i<=n;i++) {
scanf("%d",&ar[i]);
}
ll full=pw(LOG+1)-1;
for(int i=LOG;i>=0;i--) {
full-=pw(i);
if(!ok(full)) full+=pw(i);
}
printf("%lld",full);
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:114:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d",&n,&a,&b);
~~~~~^~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:118:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&ar[i]);
~~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
424 KB |
Output is correct |
3 |
Correct |
2 ms |
476 KB |
Output is correct |
4 |
Correct |
2 ms |
476 KB |
Output is correct |
5 |
Correct |
2 ms |
476 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
644 KB |
Output is correct |
8 |
Correct |
2 ms |
644 KB |
Output is correct |
9 |
Correct |
2 ms |
644 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
3 ms |
644 KB |
Output is correct |
12 |
Correct |
2 ms |
644 KB |
Output is correct |
13 |
Correct |
3 ms |
644 KB |
Output is correct |
14 |
Correct |
3 ms |
644 KB |
Output is correct |
15 |
Correct |
2 ms |
644 KB |
Output is correct |
16 |
Correct |
2 ms |
644 KB |
Output is correct |
17 |
Correct |
2 ms |
644 KB |
Output is correct |
18 |
Correct |
2 ms |
644 KB |
Output is correct |
19 |
Correct |
2 ms |
644 KB |
Output is correct |
20 |
Correct |
2 ms |
644 KB |
Output is correct |
21 |
Correct |
2 ms |
644 KB |
Output is correct |
22 |
Correct |
2 ms |
644 KB |
Output is correct |
23 |
Correct |
2 ms |
644 KB |
Output is correct |
24 |
Correct |
3 ms |
644 KB |
Output is correct |
25 |
Correct |
2 ms |
644 KB |
Output is correct |
26 |
Correct |
2 ms |
644 KB |
Output is correct |
27 |
Correct |
2 ms |
644 KB |
Output is correct |
28 |
Correct |
2 ms |
644 KB |
Output is correct |
29 |
Correct |
2 ms |
644 KB |
Output is correct |
30 |
Correct |
2 ms |
644 KB |
Output is correct |
31 |
Correct |
2 ms |
644 KB |
Output is correct |
32 |
Correct |
9 ms |
644 KB |
Output is correct |
33 |
Correct |
2 ms |
672 KB |
Output is correct |
34 |
Correct |
2 ms |
672 KB |
Output is correct |
35 |
Correct |
2 ms |
672 KB |
Output is correct |
36 |
Correct |
2 ms |
672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
672 KB |
Output is correct |
2 |
Correct |
2 ms |
672 KB |
Output is correct |
3 |
Correct |
2 ms |
672 KB |
Output is correct |
4 |
Correct |
2 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
672 KB |
Output is correct |
6 |
Correct |
2 ms |
672 KB |
Output is correct |
7 |
Correct |
2 ms |
672 KB |
Output is correct |
8 |
Correct |
2 ms |
672 KB |
Output is correct |
9 |
Correct |
2 ms |
672 KB |
Output is correct |
10 |
Correct |
2 ms |
672 KB |
Output is correct |
11 |
Correct |
2 ms |
672 KB |
Output is correct |
12 |
Correct |
2 ms |
672 KB |
Output is correct |
13 |
Correct |
2 ms |
672 KB |
Output is correct |
14 |
Correct |
2 ms |
672 KB |
Output is correct |
15 |
Correct |
2 ms |
672 KB |
Output is correct |
16 |
Correct |
3 ms |
672 KB |
Output is correct |
17 |
Correct |
3 ms |
672 KB |
Output is correct |
18 |
Correct |
2 ms |
672 KB |
Output is correct |
19 |
Correct |
3 ms |
672 KB |
Output is correct |
20 |
Correct |
2 ms |
672 KB |
Output is correct |
21 |
Correct |
2 ms |
672 KB |
Output is correct |
22 |
Correct |
2 ms |
672 KB |
Output is correct |
23 |
Correct |
2 ms |
672 KB |
Output is correct |
24 |
Correct |
2 ms |
672 KB |
Output is correct |
25 |
Correct |
3 ms |
672 KB |
Output is correct |
26 |
Correct |
3 ms |
672 KB |
Output is correct |
27 |
Correct |
2 ms |
672 KB |
Output is correct |
28 |
Correct |
2 ms |
672 KB |
Output is correct |
29 |
Correct |
2 ms |
672 KB |
Output is correct |
30 |
Correct |
2 ms |
672 KB |
Output is correct |
31 |
Correct |
2 ms |
736 KB |
Output is correct |
32 |
Correct |
2 ms |
736 KB |
Output is correct |
33 |
Correct |
2 ms |
736 KB |
Output is correct |
34 |
Correct |
3 ms |
736 KB |
Output is correct |
35 |
Correct |
2 ms |
736 KB |
Output is correct |
36 |
Correct |
2 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
736 KB |
Output is correct |
2 |
Correct |
2 ms |
736 KB |
Output is correct |
3 |
Correct |
2 ms |
736 KB |
Output is correct |
4 |
Correct |
3 ms |
736 KB |
Output is correct |
5 |
Correct |
2 ms |
736 KB |
Output is correct |
6 |
Correct |
3 ms |
736 KB |
Output is correct |
7 |
Correct |
2 ms |
736 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
3 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
3 ms |
736 KB |
Output is correct |
12 |
Correct |
3 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
736 KB |
Output is correct |
14 |
Correct |
2 ms |
736 KB |
Output is correct |
15 |
Correct |
2 ms |
736 KB |
Output is correct |
16 |
Correct |
2 ms |
736 KB |
Output is correct |
17 |
Correct |
2 ms |
736 KB |
Output is correct |
18 |
Correct |
2 ms |
736 KB |
Output is correct |
19 |
Correct |
2 ms |
736 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
2 ms |
736 KB |
Output is correct |
22 |
Correct |
2 ms |
736 KB |
Output is correct |
23 |
Correct |
2 ms |
736 KB |
Output is correct |
24 |
Correct |
2 ms |
736 KB |
Output is correct |
25 |
Correct |
3 ms |
736 KB |
Output is correct |
26 |
Correct |
2 ms |
736 KB |
Output is correct |
27 |
Correct |
3 ms |
736 KB |
Output is correct |
28 |
Correct |
3 ms |
736 KB |
Output is correct |
29 |
Correct |
3 ms |
736 KB |
Output is correct |
30 |
Correct |
3 ms |
736 KB |
Output is correct |
31 |
Correct |
3 ms |
736 KB |
Output is correct |
32 |
Correct |
3 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
736 KB |
Output is correct |
2 |
Correct |
3 ms |
736 KB |
Output is correct |
3 |
Correct |
2 ms |
736 KB |
Output is correct |
4 |
Correct |
3 ms |
736 KB |
Output is correct |
5 |
Correct |
2 ms |
736 KB |
Output is correct |
6 |
Correct |
2 ms |
736 KB |
Output is correct |
7 |
Correct |
2 ms |
736 KB |
Output is correct |
8 |
Correct |
2 ms |
736 KB |
Output is correct |
9 |
Correct |
2 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
2 ms |
736 KB |
Output is correct |
12 |
Correct |
2 ms |
736 KB |
Output is correct |
13 |
Correct |
2 ms |
736 KB |
Output is correct |
14 |
Correct |
3 ms |
736 KB |
Output is correct |
15 |
Correct |
3 ms |
736 KB |
Output is correct |
16 |
Correct |
2 ms |
736 KB |
Output is correct |
17 |
Correct |
2 ms |
736 KB |
Output is correct |
18 |
Correct |
3 ms |
736 KB |
Output is correct |
19 |
Correct |
2 ms |
736 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
3 ms |
736 KB |
Output is correct |
22 |
Correct |
3 ms |
736 KB |
Output is correct |
23 |
Correct |
2 ms |
736 KB |
Output is correct |
24 |
Correct |
2 ms |
736 KB |
Output is correct |
25 |
Correct |
3 ms |
736 KB |
Output is correct |
26 |
Correct |
3 ms |
736 KB |
Output is correct |
27 |
Correct |
2 ms |
736 KB |
Output is correct |
28 |
Correct |
2 ms |
736 KB |
Output is correct |
29 |
Correct |
3 ms |
736 KB |
Output is correct |
30 |
Correct |
2 ms |
736 KB |
Output is correct |
31 |
Correct |
2 ms |
768 KB |
Output is correct |
32 |
Correct |
2 ms |
768 KB |
Output is correct |
33 |
Correct |
3 ms |
768 KB |
Output is correct |
34 |
Correct |
2 ms |
768 KB |
Output is correct |
35 |
Correct |
3 ms |
768 KB |
Output is correct |
36 |
Correct |
2 ms |
768 KB |
Output is correct |
37 |
Correct |
2 ms |
768 KB |
Output is correct |
38 |
Correct |
2 ms |
768 KB |
Output is correct |
39 |
Correct |
2 ms |
768 KB |
Output is correct |
40 |
Correct |
2 ms |
768 KB |
Output is correct |
41 |
Correct |
3 ms |
768 KB |
Output is correct |
42 |
Correct |
2 ms |
768 KB |
Output is correct |
43 |
Correct |
3 ms |
768 KB |
Output is correct |
44 |
Correct |
2 ms |
768 KB |
Output is correct |
45 |
Correct |
2 ms |
768 KB |
Output is correct |
46 |
Correct |
2 ms |
768 KB |
Output is correct |
47 |
Correct |
2 ms |
768 KB |
Output is correct |
48 |
Correct |
3 ms |
768 KB |
Output is correct |
49 |
Correct |
3 ms |
768 KB |
Output is correct |
50 |
Correct |
3 ms |
768 KB |
Output is correct |
51 |
Correct |
3 ms |
768 KB |
Output is correct |
52 |
Correct |
3 ms |
768 KB |
Output is correct |
53 |
Correct |
3 ms |
768 KB |
Output is correct |
54 |
Correct |
3 ms |
768 KB |
Output is correct |
55 |
Correct |
3 ms |
768 KB |
Output is correct |
56 |
Correct |
2 ms |
768 KB |
Output is correct |
57 |
Correct |
3 ms |
768 KB |
Output is correct |
58 |
Correct |
3 ms |
768 KB |
Output is correct |
59 |
Correct |
2 ms |
768 KB |
Output is correct |
60 |
Correct |
3 ms |
768 KB |
Output is correct |
61 |
Correct |
3 ms |
768 KB |
Output is correct |
62 |
Correct |
2 ms |
768 KB |
Output is correct |
63 |
Correct |
3 ms |
768 KB |
Output is correct |
64 |
Correct |
7 ms |
768 KB |
Output is correct |
65 |
Correct |
3 ms |
768 KB |
Output is correct |
66 |
Correct |
4 ms |
768 KB |
Output is correct |
67 |
Correct |
4 ms |
768 KB |
Output is correct |
68 |
Correct |
4 ms |
768 KB |
Output is correct |
69 |
Correct |
5 ms |
768 KB |
Output is correct |
70 |
Correct |
5 ms |
768 KB |
Output is correct |
71 |
Correct |
4 ms |
768 KB |
Output is correct |
72 |
Correct |
5 ms |
768 KB |
Output is correct |
73 |
Correct |
5 ms |
768 KB |
Output is correct |
74 |
Correct |
4 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
768 KB |
Output is correct |
2 |
Correct |
2 ms |
768 KB |
Output is correct |
3 |
Correct |
3 ms |
768 KB |
Output is correct |
4 |
Correct |
2 ms |
768 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
768 KB |
Output is correct |
7 |
Correct |
3 ms |
768 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
3 ms |
768 KB |
Output is correct |
11 |
Correct |
2 ms |
768 KB |
Output is correct |
12 |
Correct |
2 ms |
768 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
768 KB |
Output is correct |
16 |
Correct |
2 ms |
768 KB |
Output is correct |
17 |
Correct |
2 ms |
768 KB |
Output is correct |
18 |
Correct |
2 ms |
768 KB |
Output is correct |
19 |
Correct |
2 ms |
768 KB |
Output is correct |
20 |
Correct |
2 ms |
768 KB |
Output is correct |
21 |
Correct |
2 ms |
768 KB |
Output is correct |
22 |
Correct |
2 ms |
768 KB |
Output is correct |
23 |
Correct |
2 ms |
768 KB |
Output is correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
768 KB |
Output is correct |
26 |
Correct |
2 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
2 ms |
768 KB |
Output is correct |
29 |
Correct |
3 ms |
768 KB |
Output is correct |
30 |
Correct |
2 ms |
768 KB |
Output is correct |
31 |
Correct |
2 ms |
768 KB |
Output is correct |
32 |
Correct |
2 ms |
768 KB |
Output is correct |
33 |
Correct |
2 ms |
768 KB |
Output is correct |
34 |
Correct |
2 ms |
768 KB |
Output is correct |
35 |
Correct |
4 ms |
768 KB |
Output is correct |
36 |
Correct |
3 ms |
768 KB |
Output is correct |
37 |
Correct |
4 ms |
768 KB |
Output is correct |
38 |
Correct |
3 ms |
768 KB |
Output is correct |
39 |
Correct |
3 ms |
768 KB |
Output is correct |
40 |
Correct |
4 ms |
768 KB |
Output is correct |
41 |
Correct |
3 ms |
768 KB |
Output is correct |
42 |
Correct |
3 ms |
768 KB |
Output is correct |
43 |
Correct |
2 ms |
768 KB |
Output is correct |
44 |
Correct |
2 ms |
768 KB |
Output is correct |
45 |
Correct |
3 ms |
768 KB |
Output is correct |
46 |
Correct |
2 ms |
768 KB |
Output is correct |
47 |
Correct |
2 ms |
768 KB |
Output is correct |
48 |
Correct |
3 ms |
768 KB |
Output is correct |
49 |
Correct |
3 ms |
768 KB |
Output is correct |
50 |
Correct |
3 ms |
768 KB |
Output is correct |
51 |
Correct |
3 ms |
768 KB |
Output is correct |
52 |
Correct |
17 ms |
1532 KB |
Output is correct |
53 |
Correct |
27 ms |
2300 KB |
Output is correct |
54 |
Correct |
50 ms |
3324 KB |
Output is correct |
55 |
Correct |
51 ms |
3324 KB |
Output is correct |
56 |
Correct |
186 ms |
11228 KB |
Output is correct |
57 |
Correct |
186 ms |
11288 KB |
Output is correct |
58 |
Correct |
139 ms |
11312 KB |
Output is correct |
59 |
Correct |
140 ms |
11348 KB |
Output is correct |
60 |
Correct |
217 ms |
11388 KB |
Output is correct |
61 |
Correct |
3 ms |
11388 KB |
Output is correct |
62 |
Correct |
26 ms |
11388 KB |
Output is correct |
63 |
Correct |
49 ms |
11388 KB |
Output is correct |
64 |
Correct |
43 ms |
11388 KB |
Output is correct |
65 |
Correct |
84 ms |
11388 KB |
Output is correct |
66 |
Correct |
136 ms |
11388 KB |
Output is correct |
67 |
Correct |
185 ms |
11564 KB |
Output is correct |
68 |
Correct |
171 ms |
11588 KB |
Output is correct |
69 |
Correct |
161 ms |
11604 KB |
Output is correct |