#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define ln '\n'
#define int long long
template <class _T>
bool chmin(_T &x, const _T &y){
bool flag = false;
if ( x > y ){
x = y; flag |= true;
}
return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
bool flag = false;
if ( x < y ){
x = y; flag |= true;
}
return flag;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, a, b; cin >> n >> a >> b;
vector <int> p(n);
for ( auto &i: p ) cin >> i;
const int inf = 1e15 + 1;
vector <vector<int>> dp(n + 1, vector <int> (n + 1, inf));
vector <int> pref(n + 1);
for ( int i = 0; i < n; i++ ){
pref[i + 1] = pref[i] + p[i];
}
dp[0][0] = 0;
for ( int i = 1; i <= n; i++ ){
for ( int k = 1; k <= i; k++ ){
int &res = dp[i][k];
for ( int j = 0; j + 1 <= i; j++ ){
chmin(res, dp[j][k - 1] | (pref[i] - pref[j]));
}
}
}
int Mn = inf;
for ( int i = a; i <= b; i++ ){
chmin(Mn, dp[n][i]);
}
cout << Mn;
cout << '\n';
}
/*
6 1 3
8 1 2 1 5 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |