#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define inf 2e18
#define fast_cin() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define out(file) freopen(file, "w", stdout)
#define in(file) freopen(file, "r", stdin)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
int MOD = 1e9 + 7;
const int N = 2001;
int y[N], a, b, n;
ll ps[N], dp[N][N];
signed main() {
fast_cin();
cin >> n >> a >> b;
for(int i = 1; i <= n; i++) cin >> y[i], ps[i] = ps[i-1] + y[i];
for(int i = 1; i <= n; i++) {
dp[i][0] = inf;
}
for(int j = 1; j <= b; j++) {
for(int i = j; i <= n; i++) {
dp[i][j] = inf;
for(int t = j-1; t < i; t++) {
ll cur = ps[i] - ps[t];
dp[i][j] = min(dp[i][j], dp[t][j-1] | cur);
}
}
}
// for(int i = 1; i <= n; i++) {
// for(int j = 1; j <= b; j++) {
// cout << dp[i][j] << ' ';
// }
// cout << ln;
// }
ll ans = inf;
for(int j = a; j <= b; j++) ans = min(ans, dp[n][j]);
cout << ans;
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
460 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |