#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1ll<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
const int N=2010;
int n,A,B,F[N],a[N];
ll f[N][N],s[N],kq;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("SCULPTURE.inp","r",stdin);
//freopen("SCULPTURE.out","w",stdout);
cin>>n>>A>>B;
forinc(i,1,n) cin>>a[i],s[i]=s[i-1]+a[i];
if(n<=100)
{
ll S=0;
f[0][0]=1;
fordec(i,41,1)
{
ll tg=onbit(S,i);
forinc(i,1,n) forinc(j,1,B)
{
f[i][j]=0;
forinc(t,0,i-1) if(!(tg&(s[i]-s[t]))&&f[t][j-1]) f[i][j]=1;
}
bool ok=0;
forinc(i,A,B) if(f[n][i]) ok=1;
if(ok) S=tg;
else kq=onbit(kq,i);
}
return cout<<kq,0;
}
ll S=0;
F[0]=0;
fordec(i,41,1)
{
ll tg=onbit(S,i);
forinc(i,1,n)
{
F[i]=1e4;
forinc(j,0,i-1) if(!(tg&(s[i]-s[j]))) F[i]=min(F[i],F[j]+1);
}
if(F[n]<=B) S=tg;
else kq=onbit(kq,i);
}
return cout<<kq,0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
356 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
4 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
3 ms |
512 KB |
Output is correct |
34 |
Correct |
2 ms |
384 KB |
Output is correct |
35 |
Correct |
3 ms |
512 KB |
Output is correct |
36 |
Correct |
3 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
512 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
3 ms |
512 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
512 KB |
Output is correct |
28 |
Correct |
3 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
4 ms |
512 KB |
Output is correct |
31 |
Correct |
4 ms |
512 KB |
Output is correct |
32 |
Correct |
5 ms |
512 KB |
Output is correct |
33 |
Correct |
2 ms |
512 KB |
Output is correct |
34 |
Correct |
7 ms |
512 KB |
Output is correct |
35 |
Correct |
4 ms |
512 KB |
Output is correct |
36 |
Correct |
3 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
512 KB |
Output is correct |
15 |
Correct |
3 ms |
512 KB |
Output is correct |
16 |
Correct |
2 ms |
512 KB |
Output is correct |
17 |
Correct |
4 ms |
512 KB |
Output is correct |
18 |
Correct |
4 ms |
612 KB |
Output is correct |
19 |
Correct |
4 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
4 ms |
640 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
4 ms |
512 KB |
Output is correct |
25 |
Correct |
4 ms |
628 KB |
Output is correct |
26 |
Correct |
11 ms |
640 KB |
Output is correct |
27 |
Correct |
22 ms |
768 KB |
Output is correct |
28 |
Correct |
42 ms |
768 KB |
Output is correct |
29 |
Correct |
49 ms |
768 KB |
Output is correct |
30 |
Correct |
2 ms |
768 KB |
Output is correct |
31 |
Correct |
21 ms |
768 KB |
Output is correct |
32 |
Correct |
30 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
512 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
2 ms |
512 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
2 ms |
384 KB |
Output is correct |
37 |
Correct |
3 ms |
512 KB |
Output is correct |
38 |
Correct |
3 ms |
512 KB |
Output is correct |
39 |
Correct |
3 ms |
512 KB |
Output is correct |
40 |
Correct |
3 ms |
512 KB |
Output is correct |
41 |
Correct |
4 ms |
640 KB |
Output is correct |
42 |
Correct |
5 ms |
640 KB |
Output is correct |
43 |
Correct |
2 ms |
512 KB |
Output is correct |
44 |
Correct |
6 ms |
512 KB |
Output is correct |
45 |
Correct |
5 ms |
512 KB |
Output is correct |
46 |
Correct |
4 ms |
512 KB |
Output is correct |
47 |
Correct |
4 ms |
512 KB |
Output is correct |
48 |
Correct |
3 ms |
640 KB |
Output is correct |
49 |
Correct |
8 ms |
640 KB |
Output is correct |
50 |
Correct |
19 ms |
768 KB |
Output is correct |
51 |
Correct |
38 ms |
768 KB |
Output is correct |
52 |
Correct |
52 ms |
900 KB |
Output is correct |
53 |
Correct |
4 ms |
768 KB |
Output is correct |
54 |
Correct |
20 ms |
768 KB |
Output is correct |
55 |
Correct |
30 ms |
852 KB |
Output is correct |
56 |
Correct |
6 ms |
640 KB |
Output is correct |
57 |
Correct |
7 ms |
640 KB |
Output is correct |
58 |
Correct |
16 ms |
768 KB |
Output is correct |
59 |
Correct |
30 ms |
896 KB |
Output is correct |
60 |
Correct |
31 ms |
768 KB |
Output is correct |
61 |
Correct |
3 ms |
768 KB |
Output is correct |
62 |
Correct |
40 ms |
896 KB |
Output is correct |
63 |
Correct |
39 ms |
896 KB |
Output is correct |
64 |
Correct |
28 ms |
768 KB |
Output is correct |
65 |
Correct |
4 ms |
640 KB |
Output is correct |
66 |
Correct |
5 ms |
640 KB |
Output is correct |
67 |
Correct |
7 ms |
640 KB |
Output is correct |
68 |
Correct |
19 ms |
768 KB |
Output is correct |
69 |
Correct |
35 ms |
768 KB |
Output is correct |
70 |
Correct |
32 ms |
768 KB |
Output is correct |
71 |
Correct |
4 ms |
768 KB |
Output is correct |
72 |
Correct |
51 ms |
904 KB |
Output is correct |
73 |
Correct |
34 ms |
888 KB |
Output is correct |
74 |
Correct |
27 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
512 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
640 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
512 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
640 KB |
Output is correct |
27 |
Correct |
4 ms |
512 KB |
Output is correct |
28 |
Correct |
6 ms |
640 KB |
Output is correct |
29 |
Correct |
5 ms |
512 KB |
Output is correct |
30 |
Correct |
3 ms |
640 KB |
Output is correct |
31 |
Correct |
7 ms |
640 KB |
Output is correct |
32 |
Correct |
5 ms |
640 KB |
Output is correct |
33 |
Correct |
3 ms |
512 KB |
Output is correct |
34 |
Correct |
4 ms |
640 KB |
Output is correct |
35 |
Correct |
4 ms |
640 KB |
Output is correct |
36 |
Correct |
8 ms |
640 KB |
Output is correct |
37 |
Correct |
27 ms |
768 KB |
Output is correct |
38 |
Correct |
46 ms |
900 KB |
Output is correct |
39 |
Correct |
38 ms |
896 KB |
Output is correct |
40 |
Correct |
4 ms |
768 KB |
Output is correct |
41 |
Correct |
17 ms |
768 KB |
Output is correct |
42 |
Correct |
36 ms |
852 KB |
Output is correct |
43 |
Correct |
5 ms |
640 KB |
Output is correct |
44 |
Correct |
8 ms |
640 KB |
Output is correct |
45 |
Correct |
20 ms |
768 KB |
Output is correct |
46 |
Correct |
31 ms |
768 KB |
Output is correct |
47 |
Correct |
32 ms |
896 KB |
Output is correct |
48 |
Correct |
3 ms |
768 KB |
Output is correct |
49 |
Correct |
47 ms |
860 KB |
Output is correct |
50 |
Correct |
44 ms |
768 KB |
Output is correct |
51 |
Correct |
2 ms |
384 KB |
Output is correct |
52 |
Correct |
10 ms |
384 KB |
Output is correct |
53 |
Correct |
15 ms |
384 KB |
Output is correct |
54 |
Correct |
26 ms |
384 KB |
Output is correct |
55 |
Correct |
24 ms |
384 KB |
Output is correct |
56 |
Correct |
81 ms |
412 KB |
Output is correct |
57 |
Correct |
78 ms |
504 KB |
Output is correct |
58 |
Correct |
75 ms |
384 KB |
Output is correct |
59 |
Correct |
73 ms |
384 KB |
Output is correct |
60 |
Correct |
95 ms |
384 KB |
Output is correct |
61 |
Correct |
4 ms |
384 KB |
Output is correct |
62 |
Correct |
14 ms |
384 KB |
Output is correct |
63 |
Correct |
26 ms |
384 KB |
Output is correct |
64 |
Correct |
21 ms |
384 KB |
Output is correct |
65 |
Correct |
44 ms |
448 KB |
Output is correct |
66 |
Correct |
56 ms |
384 KB |
Output is correct |
67 |
Correct |
75 ms |
384 KB |
Output is correct |
68 |
Correct |
84 ms |
384 KB |
Output is correct |
69 |
Correct |
118 ms |
384 KB |
Output is correct |