#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
const ll INF=1e18;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,a,b;
cin>>n>>a>>b;
ll ans=INF;
ll y[n+5];
for(ll i=1;i<=n;i++){
cin>>y[i];
}
ll p=(1ll<<(n-1));
for(ll i=0;i<p;i++){
ll d=1;
ll x=i;
ll cur=y[1];
ll res=0;
for(ll j=2;j<=n;j++){
if(x%2==1){
d++;
res|=cur;
cur=y[j];
}
else{
cur+=y[j];
}
x/=2;
}
if(a<=d&&d<=b){
res|=cur;
ans=min(ans,res);
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
320 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Correct |
29 ms |
212 KB |
Output is correct |
9 |
Correct |
29 ms |
296 KB |
Output is correct |
10 |
Correct |
30 ms |
300 KB |
Output is correct |
11 |
Correct |
30 ms |
300 KB |
Output is correct |
12 |
Correct |
28 ms |
212 KB |
Output is correct |
13 |
Correct |
29 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
316 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
320 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
4 ms |
212 KB |
Output is correct |
21 |
Correct |
33 ms |
212 KB |
Output is correct |
22 |
Correct |
27 ms |
300 KB |
Output is correct |
23 |
Correct |
28 ms |
212 KB |
Output is correct |
24 |
Correct |
28 ms |
212 KB |
Output is correct |
25 |
Correct |
28 ms |
212 KB |
Output is correct |
26 |
Correct |
31 ms |
296 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
324 KB |
Output is correct |
29 |
Correct |
1 ms |
328 KB |
Output is correct |
30 |
Correct |
14 ms |
316 KB |
Output is correct |
31 |
Correct |
30 ms |
332 KB |
Output is correct |
32 |
Correct |
27 ms |
304 KB |
Output is correct |
33 |
Correct |
28 ms |
212 KB |
Output is correct |
34 |
Correct |
32 ms |
212 KB |
Output is correct |
35 |
Correct |
30 ms |
212 KB |
Output is correct |
36 |
Correct |
31 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Correct |
30 ms |
212 KB |
Output is correct |
9 |
Correct |
28 ms |
296 KB |
Output is correct |
10 |
Correct |
28 ms |
212 KB |
Output is correct |
11 |
Correct |
30 ms |
304 KB |
Output is correct |
12 |
Correct |
28 ms |
212 KB |
Output is correct |
13 |
Correct |
28 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
316 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
1 ms |
320 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
4 ms |
212 KB |
Output is correct |
21 |
Correct |
28 ms |
212 KB |
Output is correct |
22 |
Correct |
28 ms |
212 KB |
Output is correct |
23 |
Correct |
28 ms |
212 KB |
Output is correct |
24 |
Correct |
29 ms |
212 KB |
Output is correct |
25 |
Correct |
29 ms |
212 KB |
Output is correct |
26 |
Correct |
29 ms |
212 KB |
Output is correct |
27 |
Correct |
55 ms |
300 KB |
Output is correct |
28 |
Correct |
996 ms |
296 KB |
Output is correct |
29 |
Execution timed out |
1057 ms |
212 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
320 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Correct |
28 ms |
320 KB |
Output is correct |
9 |
Correct |
29 ms |
212 KB |
Output is correct |
10 |
Correct |
29 ms |
212 KB |
Output is correct |
11 |
Correct |
32 ms |
212 KB |
Output is correct |
12 |
Correct |
31 ms |
316 KB |
Output is correct |
13 |
Correct |
28 ms |
212 KB |
Output is correct |
14 |
Correct |
59 ms |
212 KB |
Output is correct |
15 |
Execution timed out |
1018 ms |
308 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Correct |
38 ms |
212 KB |
Output is correct |
9 |
Correct |
29 ms |
212 KB |
Output is correct |
10 |
Correct |
37 ms |
212 KB |
Output is correct |
11 |
Correct |
28 ms |
212 KB |
Output is correct |
12 |
Correct |
28 ms |
300 KB |
Output is correct |
13 |
Correct |
29 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
4 ms |
316 KB |
Output is correct |
21 |
Correct |
29 ms |
212 KB |
Output is correct |
22 |
Correct |
30 ms |
212 KB |
Output is correct |
23 |
Correct |
36 ms |
212 KB |
Output is correct |
24 |
Correct |
29 ms |
312 KB |
Output is correct |
25 |
Correct |
29 ms |
212 KB |
Output is correct |
26 |
Correct |
29 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
15 ms |
324 KB |
Output is correct |
31 |
Correct |
29 ms |
212 KB |
Output is correct |
32 |
Correct |
37 ms |
212 KB |
Output is correct |
33 |
Correct |
27 ms |
212 KB |
Output is correct |
34 |
Correct |
29 ms |
212 KB |
Output is correct |
35 |
Correct |
30 ms |
212 KB |
Output is correct |
36 |
Correct |
31 ms |
212 KB |
Output is correct |
37 |
Correct |
64 ms |
296 KB |
Output is correct |
38 |
Execution timed out |
1041 ms |
300 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
328 KB |
Output is correct |
8 |
Correct |
31 ms |
212 KB |
Output is correct |
9 |
Correct |
33 ms |
300 KB |
Output is correct |
10 |
Correct |
31 ms |
212 KB |
Output is correct |
11 |
Correct |
28 ms |
296 KB |
Output is correct |
12 |
Correct |
31 ms |
304 KB |
Output is correct |
13 |
Correct |
30 ms |
300 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
18 ms |
212 KB |
Output is correct |
18 |
Correct |
30 ms |
212 KB |
Output is correct |
19 |
Correct |
28 ms |
212 KB |
Output is correct |
20 |
Correct |
31 ms |
212 KB |
Output is correct |
21 |
Correct |
30 ms |
300 KB |
Output is correct |
22 |
Correct |
31 ms |
212 KB |
Output is correct |
23 |
Correct |
33 ms |
304 KB |
Output is correct |
24 |
Correct |
65 ms |
300 KB |
Output is correct |
25 |
Execution timed out |
1064 ms |
212 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |