#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
#define ll long long
#define pb push_back
using namespace std;
long long int n,a,b,y[21];
long long int inf = (long long)1e17+17;
long long int ans=inf;
void do_job(int pos,int sep,ll sum, ll ret)
{
if(pos==n){
if(a<=sep && sep<=b)ans=min(ans,sum|ret);
return;
}
do_job(pos+1,sep,sum+y[pos],ret);
do_job(pos+1,sep+1,y[pos],sum|ret);
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>a>>b;
for(int i=0;i<n;i++)cin>>y[i];
do_job(1,1,y[0],0);
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
4 ms |
212 KB |
Output is correct |
9 |
Correct |
5 ms |
316 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
212 KB |
Output is correct |
22 |
Correct |
3 ms |
212 KB |
Output is correct |
23 |
Correct |
3 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
212 KB |
Output is correct |
25 |
Correct |
3 ms |
212 KB |
Output is correct |
26 |
Correct |
3 ms |
320 KB |
Output is correct |
27 |
Correct |
0 ms |
316 KB |
Output is correct |
28 |
Correct |
1 ms |
320 KB |
Output is correct |
29 |
Correct |
1 ms |
324 KB |
Output is correct |
30 |
Correct |
2 ms |
324 KB |
Output is correct |
31 |
Correct |
3 ms |
212 KB |
Output is correct |
32 |
Correct |
4 ms |
220 KB |
Output is correct |
33 |
Correct |
5 ms |
324 KB |
Output is correct |
34 |
Correct |
3 ms |
316 KB |
Output is correct |
35 |
Correct |
3 ms |
320 KB |
Output is correct |
36 |
Correct |
3 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
320 KB |
Output is correct |
9 |
Correct |
3 ms |
316 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
324 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
320 KB |
Output is correct |
22 |
Correct |
3 ms |
212 KB |
Output is correct |
23 |
Correct |
3 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
324 KB |
Output is correct |
25 |
Correct |
3 ms |
328 KB |
Output is correct |
26 |
Correct |
4 ms |
320 KB |
Output is correct |
27 |
Correct |
5 ms |
316 KB |
Output is correct |
28 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
320 KB |
Output is correct |
5 |
Correct |
0 ms |
320 KB |
Output is correct |
6 |
Correct |
0 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
324 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
212 KB |
Output is correct |
14 |
Correct |
5 ms |
212 KB |
Output is correct |
15 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
16 |
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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
316 KB |
Output is correct |
10 |
Correct |
3 ms |
316 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
324 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
320 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
212 KB |
Output is correct |
22 |
Correct |
3 ms |
212 KB |
Output is correct |
23 |
Correct |
4 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
212 KB |
Output is correct |
25 |
Correct |
3 ms |
320 KB |
Output is correct |
26 |
Correct |
3 ms |
320 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
320 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
3 ms |
212 KB |
Output is correct |
32 |
Correct |
3 ms |
320 KB |
Output is correct |
33 |
Correct |
3 ms |
212 KB |
Output is correct |
34 |
Correct |
3 ms |
212 KB |
Output is correct |
35 |
Correct |
3 ms |
212 KB |
Output is correct |
36 |
Correct |
3 ms |
312 KB |
Output is correct |
37 |
Correct |
6 ms |
316 KB |
Output is correct |
38 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
320 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
2 ms |
212 KB |
Output is correct |
18 |
Correct |
3 ms |
212 KB |
Output is correct |
19 |
Correct |
3 ms |
212 KB |
Output is correct |
20 |
Correct |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
212 KB |
Output is correct |
22 |
Correct |
3 ms |
212 KB |
Output is correct |
23 |
Correct |
3 ms |
212 KB |
Output is correct |
24 |
Correct |
5 ms |
212 KB |
Output is correct |
25 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |