#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int n, l, r; cin >> n >> l >> r;
vector<int> a(n + 1), pref(n + 1);
for (int i = 1; i <= n; i++){
cin >> a[i];
pref[i] = pref[i - 1] + a[i];
}
vector<vector<int>> dp(n + 1, vector<int> (n + 1, 1e9 + 10));
dp[0][0] = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= i; j++){
for (int k = 0; k < i; k++){
int x = pref[i] - pref[k];
dp[i][j] = min(dp[i][j], (dp[k][j - 1] | x));
}
}
}
/*for (int i = 1; i <= n; i++){
for (int j = 0; j <= n; j++){
cout << dp[i][j] << ' ';
}
cout << endl;
}*/
int ans = dp[n][1];
for (int i = l; i <= r; i++){
ans = min(dp[n][i], ans);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |