#include <bits/stdc++.h>
#define st first
#define nd second
using namespace std;
const long long INF = 1e12;
const int MOD = 1e9+7;
const int MAXN = 30000;
int n, l, r;
long long v[200], sum[200];
long long dp[200][200];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> l >> r;
long long sm = 0;
for(int i = 0; i <= n; i++)
for(int j = 0; j <= n; j++)
dp[i][j] = INF;
for(int i = 1; i <= n; i++) {
cin >> v[i];
sm += v[i];
sum[i] = sm;
dp[i][1] = sm;
}
for(int i = 2; i <= n; i++)
for(int k = 2; k <= i; k++){
for(int j = i-1; j > 0; j--)
dp[i][k] = min(dp[i][k],dp[j][k-1]|(sum[i]-sum[j]));
}
long long ans = INF;
for(int i = l; i <= r; i++)
ans = min(ans,dp[n][i]);
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
424 KB |
Output is correct |
2 |
Incorrect |
2 ms |
524 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
528 KB |
Output is correct |
2 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
600 KB |
Output is correct |
2 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |