#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+4;
const ll inf = 1ll<<60;
int n,L,R;
ll dp[N][N],pr[N],ans;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> L >> R;
for (int i=1; i<=n; i++){ cin >> pr[i]; pr[i] += pr[i-1];}
for (int i=0; i<=n; i++) for (int j=0; j<=R; j++) dp[i][j] = inf;
dp[0][0] = 0;
for (int i=1; i<=n; i++) for (int j=1; j<=R; j++) for (int k=0; k<i; k++)
dp[i][j] = min(dp[i][j], dp[k][j-1]|(pr[i] - pr[k]));
ans = inf;
for (int j=L; j<=R; j++) ans = min(ans, dp[n][j]);
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 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 |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 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 |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |