#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int arr[2001];
int dp[2002][2011];
int place;
long long res=0;
int get(int cur,int r){
if(cur==n+1){
if(a<=r && r<=b)return 1;
return 0;
}
if(dp[cur][r]!=-1)return dp[cur][r];
long long sum=0;
int ok=0;
for(int i=cur;i<=n;i++){
sum+=arr[i];
if((res >> (place+1))==((res|sum) >> (place+1))){
if((sum & (1LL << place))==0)
ok=max(ok,get(i+1,r+1));
}
}
return dp[cur][r]=ok;
}
int main(void){
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >>n >> a >> b;
for(int i=1;i<=n;i++)
cin >> arr[i];
for(place=40;place>=0;place--){
memset(dp,-1,sizeof(dp));
if(!get(1,0)){
res+=(1LL << place);
}
}
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
16068 KB |
Output is correct |
2 |
Correct |
87 ms |
16052 KB |
Output is correct |
3 |
Correct |
83 ms |
16056 KB |
Output is correct |
4 |
Correct |
80 ms |
15948 KB |
Output is correct |
5 |
Correct |
81 ms |
16076 KB |
Output is correct |
6 |
Correct |
83 ms |
16068 KB |
Output is correct |
7 |
Correct |
87 ms |
16068 KB |
Output is correct |
8 |
Correct |
85 ms |
16076 KB |
Output is correct |
9 |
Correct |
82 ms |
15948 KB |
Output is correct |
10 |
Correct |
83 ms |
16056 KB |
Output is correct |
11 |
Correct |
88 ms |
16056 KB |
Output is correct |
12 |
Correct |
87 ms |
16076 KB |
Output is correct |
13 |
Correct |
83 ms |
16052 KB |
Output is correct |
14 |
Correct |
81 ms |
15948 KB |
Output is correct |
15 |
Correct |
84 ms |
16008 KB |
Output is correct |
16 |
Correct |
82 ms |
16052 KB |
Output is correct |
17 |
Correct |
86 ms |
16076 KB |
Output is correct |
18 |
Correct |
84 ms |
15948 KB |
Output is correct |
19 |
Correct |
83 ms |
16052 KB |
Output is correct |
20 |
Correct |
83 ms |
16068 KB |
Output is correct |
21 |
Correct |
85 ms |
15948 KB |
Output is correct |
22 |
Correct |
82 ms |
15948 KB |
Output is correct |
23 |
Correct |
84 ms |
15948 KB |
Output is correct |
24 |
Correct |
84 ms |
16052 KB |
Output is correct |
25 |
Correct |
85 ms |
15992 KB |
Output is correct |
26 |
Correct |
83 ms |
16052 KB |
Output is correct |
27 |
Correct |
84 ms |
16076 KB |
Output is correct |
28 |
Correct |
85 ms |
16056 KB |
Output is correct |
29 |
Correct |
85 ms |
16008 KB |
Output is correct |
30 |
Correct |
86 ms |
15948 KB |
Output is correct |
31 |
Correct |
85 ms |
16068 KB |
Output is correct |
32 |
Correct |
81 ms |
16076 KB |
Output is correct |
33 |
Correct |
87 ms |
15948 KB |
Output is correct |
34 |
Correct |
90 ms |
16068 KB |
Output is correct |
35 |
Correct |
83 ms |
15948 KB |
Output is correct |
36 |
Correct |
84 ms |
16072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
82 ms |
15948 KB |
Output is correct |
2 |
Correct |
84 ms |
15964 KB |
Output is correct |
3 |
Correct |
86 ms |
16052 KB |
Output is correct |
4 |
Correct |
84 ms |
16068 KB |
Output is correct |
5 |
Correct |
86 ms |
16052 KB |
Output is correct |
6 |
Correct |
83 ms |
16056 KB |
Output is correct |
7 |
Correct |
84 ms |
15948 KB |
Output is correct |
8 |
Correct |
82 ms |
16076 KB |
Output is correct |
9 |
Correct |
85 ms |
16076 KB |
Output is correct |
10 |
Correct |
84 ms |
15948 KB |
Output is correct |
11 |
Correct |
86 ms |
16004 KB |
Output is correct |
12 |
Correct |
85 ms |
16036 KB |
Output is correct |
13 |
Correct |
83 ms |
16052 KB |
Output is correct |
14 |
Correct |
82 ms |
16068 KB |
Output is correct |
15 |
Correct |
84 ms |
16052 KB |
Output is correct |
16 |
Correct |
84 ms |
16056 KB |
Output is correct |
17 |
Correct |
82 ms |
15948 KB |
Output is correct |
18 |
Correct |
82 ms |
16076 KB |
Output is correct |
19 |
Correct |
87 ms |
15964 KB |
Output is correct |
20 |
Correct |
84 ms |
16076 KB |
Output is correct |
21 |
Correct |
85 ms |
16056 KB |
Output is correct |
22 |
Correct |
85 ms |
16016 KB |
Output is correct |
23 |
Correct |
81 ms |
15948 KB |
Output is correct |
24 |
Correct |
84 ms |
16068 KB |
Output is correct |
25 |
Correct |
85 ms |
16068 KB |
Output is correct |
26 |
Correct |
84 ms |
15948 KB |
Output is correct |
27 |
Correct |
83 ms |
15948 KB |
Output is correct |
28 |
Correct |
82 ms |
16060 KB |
Output is correct |
29 |
Correct |
86 ms |
16036 KB |
Output is correct |
30 |
Correct |
90 ms |
16076 KB |
Output is correct |
31 |
Correct |
91 ms |
16076 KB |
Output is correct |
32 |
Correct |
89 ms |
15948 KB |
Output is correct |
33 |
Correct |
92 ms |
16056 KB |
Output is correct |
34 |
Correct |
88 ms |
16052 KB |
Output is correct |
35 |
Correct |
88 ms |
16052 KB |
Output is correct |
36 |
Correct |
91 ms |
16064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
15948 KB |
Output is correct |
2 |
Correct |
86 ms |
16056 KB |
Output is correct |
3 |
Correct |
87 ms |
16076 KB |
Output is correct |
4 |
Correct |
82 ms |
15948 KB |
Output is correct |
5 |
Correct |
85 ms |
16068 KB |
Output is correct |
6 |
Correct |
90 ms |
16076 KB |
Output is correct |
7 |
Correct |
85 ms |
15948 KB |
Output is correct |
8 |
Correct |
86 ms |
16052 KB |
Output is correct |
9 |
Correct |
83 ms |
16056 KB |
Output is correct |
10 |
Correct |
84 ms |
15948 KB |
Output is correct |
11 |
Correct |
84 ms |
16056 KB |
Output is correct |
12 |
Correct |
88 ms |
15948 KB |
Output is correct |
13 |
Correct |
83 ms |
15948 KB |
Output is correct |
14 |
Correct |
82 ms |
16076 KB |
Output is correct |
15 |
Correct |
89 ms |
16056 KB |
Output is correct |
16 |
Correct |
86 ms |
15948 KB |
Output is correct |
17 |
Correct |
85 ms |
16068 KB |
Output is correct |
18 |
Correct |
87 ms |
15952 KB |
Output is correct |
19 |
Correct |
91 ms |
15948 KB |
Output is correct |
20 |
Correct |
87 ms |
16016 KB |
Output is correct |
21 |
Correct |
88 ms |
15988 KB |
Output is correct |
22 |
Correct |
91 ms |
16020 KB |
Output is correct |
23 |
Correct |
89 ms |
16076 KB |
Output is correct |
24 |
Correct |
87 ms |
15948 KB |
Output is correct |
25 |
Correct |
96 ms |
15956 KB |
Output is correct |
26 |
Correct |
103 ms |
15948 KB |
Output is correct |
27 |
Correct |
118 ms |
16056 KB |
Output is correct |
28 |
Correct |
120 ms |
15948 KB |
Output is correct |
29 |
Correct |
126 ms |
15948 KB |
Output is correct |
30 |
Correct |
123 ms |
16076 KB |
Output is correct |
31 |
Correct |
122 ms |
16068 KB |
Output is correct |
32 |
Correct |
120 ms |
15984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
83 ms |
16076 KB |
Output is correct |
2 |
Correct |
83 ms |
16052 KB |
Output is correct |
3 |
Correct |
82 ms |
16056 KB |
Output is correct |
4 |
Correct |
84 ms |
15952 KB |
Output is correct |
5 |
Correct |
83 ms |
15948 KB |
Output is correct |
6 |
Correct |
84 ms |
15948 KB |
Output is correct |
7 |
Correct |
86 ms |
15948 KB |
Output is correct |
8 |
Correct |
82 ms |
16076 KB |
Output is correct |
9 |
Correct |
82 ms |
16076 KB |
Output is correct |
10 |
Correct |
85 ms |
15948 KB |
Output is correct |
11 |
Correct |
83 ms |
16076 KB |
Output is correct |
12 |
Correct |
84 ms |
16056 KB |
Output is correct |
13 |
Correct |
83 ms |
16052 KB |
Output is correct |
14 |
Correct |
83 ms |
16076 KB |
Output is correct |
15 |
Correct |
84 ms |
15948 KB |
Output is correct |
16 |
Correct |
84 ms |
15948 KB |
Output is correct |
17 |
Correct |
81 ms |
15948 KB |
Output is correct |
18 |
Correct |
84 ms |
15948 KB |
Output is correct |
19 |
Correct |
85 ms |
15948 KB |
Output is correct |
20 |
Correct |
85 ms |
16056 KB |
Output is correct |
21 |
Correct |
87 ms |
16052 KB |
Output is correct |
22 |
Correct |
86 ms |
16076 KB |
Output is correct |
23 |
Correct |
82 ms |
15948 KB |
Output is correct |
24 |
Correct |
84 ms |
15972 KB |
Output is correct |
25 |
Correct |
83 ms |
16076 KB |
Output is correct |
26 |
Correct |
86 ms |
16068 KB |
Output is correct |
27 |
Correct |
82 ms |
16056 KB |
Output is correct |
28 |
Correct |
82 ms |
15948 KB |
Output is correct |
29 |
Correct |
82 ms |
16064 KB |
Output is correct |
30 |
Correct |
82 ms |
15948 KB |
Output is correct |
31 |
Correct |
87 ms |
16076 KB |
Output is correct |
32 |
Correct |
91 ms |
16056 KB |
Output is correct |
33 |
Correct |
87 ms |
16076 KB |
Output is correct |
34 |
Correct |
84 ms |
16056 KB |
Output is correct |
35 |
Correct |
85 ms |
16008 KB |
Output is correct |
36 |
Correct |
83 ms |
15948 KB |
Output is correct |
37 |
Correct |
87 ms |
16064 KB |
Output is correct |
38 |
Correct |
91 ms |
16056 KB |
Output is correct |
39 |
Correct |
90 ms |
16064 KB |
Output is correct |
40 |
Correct |
88 ms |
16172 KB |
Output is correct |
41 |
Correct |
91 ms |
15948 KB |
Output is correct |
42 |
Correct |
91 ms |
16064 KB |
Output is correct |
43 |
Correct |
91 ms |
16056 KB |
Output is correct |
44 |
Correct |
87 ms |
15948 KB |
Output is correct |
45 |
Correct |
89 ms |
16076 KB |
Output is correct |
46 |
Correct |
89 ms |
16056 KB |
Output is correct |
47 |
Correct |
90 ms |
15948 KB |
Output is correct |
48 |
Correct |
100 ms |
16056 KB |
Output is correct |
49 |
Correct |
103 ms |
16064 KB |
Output is correct |
50 |
Correct |
112 ms |
16076 KB |
Output is correct |
51 |
Correct |
122 ms |
16076 KB |
Output is correct |
52 |
Correct |
119 ms |
16076 KB |
Output is correct |
53 |
Correct |
120 ms |
16060 KB |
Output is correct |
54 |
Correct |
121 ms |
16072 KB |
Output is correct |
55 |
Correct |
121 ms |
16056 KB |
Output is correct |
56 |
Correct |
83 ms |
16056 KB |
Output is correct |
57 |
Correct |
88 ms |
16076 KB |
Output is correct |
58 |
Correct |
93 ms |
16064 KB |
Output is correct |
59 |
Correct |
93 ms |
16076 KB |
Output is correct |
60 |
Correct |
90 ms |
16056 KB |
Output is correct |
61 |
Correct |
90 ms |
16056 KB |
Output is correct |
62 |
Correct |
93 ms |
16056 KB |
Output is correct |
63 |
Correct |
100 ms |
15956 KB |
Output is correct |
64 |
Correct |
115 ms |
16076 KB |
Output is correct |
65 |
Correct |
84 ms |
16056 KB |
Output is correct |
66 |
Correct |
85 ms |
15948 KB |
Output is correct |
67 |
Correct |
93 ms |
16052 KB |
Output is correct |
68 |
Correct |
93 ms |
16056 KB |
Output is correct |
69 |
Correct |
91 ms |
16060 KB |
Output is correct |
70 |
Correct |
94 ms |
15948 KB |
Output is correct |
71 |
Correct |
94 ms |
16076 KB |
Output is correct |
72 |
Correct |
94 ms |
16064 KB |
Output is correct |
73 |
Correct |
95 ms |
16056 KB |
Output is correct |
74 |
Correct |
97 ms |
16076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
81 ms |
15948 KB |
Output is correct |
2 |
Correct |
82 ms |
15952 KB |
Output is correct |
3 |
Correct |
85 ms |
16060 KB |
Output is correct |
4 |
Correct |
86 ms |
15948 KB |
Output is correct |
5 |
Correct |
82 ms |
16068 KB |
Output is correct |
6 |
Correct |
81 ms |
15948 KB |
Output is correct |
7 |
Correct |
85 ms |
16056 KB |
Output is correct |
8 |
Correct |
84 ms |
16056 KB |
Output is correct |
9 |
Correct |
82 ms |
16076 KB |
Output is correct |
10 |
Correct |
84 ms |
16004 KB |
Output is correct |
11 |
Correct |
83 ms |
16068 KB |
Output is correct |
12 |
Correct |
83 ms |
16028 KB |
Output is correct |
13 |
Correct |
84 ms |
16056 KB |
Output is correct |
14 |
Correct |
84 ms |
15948 KB |
Output is correct |
15 |
Correct |
89 ms |
15948 KB |
Output is correct |
16 |
Correct |
86 ms |
16076 KB |
Output is correct |
17 |
Correct |
87 ms |
16052 KB |
Output is correct |
18 |
Correct |
85 ms |
16076 KB |
Output is correct |
19 |
Correct |
85 ms |
16056 KB |
Output is correct |
20 |
Correct |
85 ms |
15948 KB |
Output is correct |
21 |
Correct |
83 ms |
16052 KB |
Output is correct |
22 |
Correct |
86 ms |
16076 KB |
Output is correct |
23 |
Correct |
87 ms |
16052 KB |
Output is correct |
24 |
Correct |
83 ms |
16004 KB |
Output is correct |
25 |
Correct |
84 ms |
15948 KB |
Output is correct |
26 |
Correct |
85 ms |
15948 KB |
Output is correct |
27 |
Correct |
87 ms |
15948 KB |
Output is correct |
28 |
Correct |
90 ms |
16056 KB |
Output is correct |
29 |
Correct |
87 ms |
15948 KB |
Output is correct |
30 |
Correct |
93 ms |
16056 KB |
Output is correct |
31 |
Correct |
90 ms |
15948 KB |
Output is correct |
32 |
Correct |
94 ms |
15948 KB |
Output is correct |
33 |
Correct |
88 ms |
16052 KB |
Output is correct |
34 |
Correct |
88 ms |
16076 KB |
Output is correct |
35 |
Correct |
99 ms |
16068 KB |
Output is correct |
36 |
Correct |
101 ms |
16076 KB |
Output is correct |
37 |
Correct |
112 ms |
16076 KB |
Output is correct |
38 |
Correct |
125 ms |
16068 KB |
Output is correct |
39 |
Correct |
133 ms |
16076 KB |
Output is correct |
40 |
Correct |
125 ms |
16076 KB |
Output is correct |
41 |
Correct |
120 ms |
15948 KB |
Output is correct |
42 |
Correct |
119 ms |
16056 KB |
Output is correct |
43 |
Correct |
85 ms |
16056 KB |
Output is correct |
44 |
Correct |
89 ms |
15948 KB |
Output is correct |
45 |
Correct |
90 ms |
16076 KB |
Output is correct |
46 |
Correct |
93 ms |
16076 KB |
Output is correct |
47 |
Correct |
91 ms |
16056 KB |
Output is correct |
48 |
Correct |
94 ms |
16076 KB |
Output is correct |
49 |
Correct |
96 ms |
16076 KB |
Output is correct |
50 |
Correct |
101 ms |
16060 KB |
Output is correct |
51 |
Correct |
93 ms |
15948 KB |
Output is correct |
52 |
Execution timed out |
1082 ms |
16076 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |