#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define sz(x) (ll)(x).size()
#define all(x) x.begin(),x.end()
#define inf 1000000000000000000
vi Y;
ll n,a,b;
ll cnt(ll m){
ll ans = 0;
while(m > 0){
ans += m%2;
m /= 2;
}
return ans;
}
int main(){
cin >> n >> a >> b;
Y.assign(n,0);
rep(i,0,n) cin >> Y[i];
if (n > 20) exit(0);
ll best = inf,cur;
rep(x,0,(1<<(n-1))){
ll X = cnt(x);
cur = 0;
if (X > b || X < a) continue;
ll t = x,last = 0;
rep(i,1,n){
if (t%2){
ll temp = 0;
rep(j,last,i) temp += Y[j];
cur |= temp;
last = i;
}
t /= 2;
}
ll temp = 0;
rep(j,last,n) temp += Y[j];
cur |= temp;
best = min(best,cur);
}
cout << best << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Incorrect |
3 ms |
484 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
524 KB |
Output is correct |
2 |
Correct |
3 ms |
568 KB |
Output is correct |
3 |
Incorrect |
3 ms |
568 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
820 KB |
Output is correct |
2 |
Correct |
2 ms |
820 KB |
Output is correct |
3 |
Incorrect |
3 ms |
820 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
820 KB |
Output is correct |
2 |
Correct |
3 ms |
876 KB |
Output is correct |
3 |
Incorrect |
3 ms |
876 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
876 KB |
Output is correct |
2 |
Correct |
3 ms |
876 KB |
Output is correct |
3 |
Incorrect |
3 ms |
876 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |