#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
const int MAXN = 2100;
const ll INF = 1e17;
int n, a, b;
ll y[MAXN];
ll pref[MAXN];
ll dp[MAXN][MAXN];
int main()
{
FAST_IO;
cin >> n >> a >> b;
FOR(i, 1, n) cin >> y[i];
FOR(i, 1, n) pref[i] = pref[i-1] + y[i];
FOR(i, 0, n) FOR(g, 0, n) dp[i][g] = INF;
dp[0][0] = 0;
FOR(i, 1, n) FOR(g, 1, i) {
FOR(j, g-1, i-1) {
ll cur = dp[j][g-1] | (pref[i] - pref[j]);
dp[i][g] = min(dp[i][g], cur);
}
//cout << " i = " << i << " g = " << g << " dp = " << dp[i][g] << endl;
}
ll ans = INF;
FOR(x, a, b)
ans = min(ans, dp[n][x]);
cout << ans << "\n";
return 0;
}
/*
in:
6 1 3
8 1 2 1 5 4
ans: 11
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |