#include<bits/stdc++.h>
using namespace std;
const long long maxn = 2048;
long long n,a,b;
long long age[maxn];
long long par[maxn];
long long dp[maxn][maxn];
void read()
{
cin >> n >> a >> b;
for( long long i = 1; i <= n; i ++ )
cin >> age[i];
}
void solve()
{
memset(dp,-1,sizeof(dp));
for( long long i = 1; i <= n; i ++ )
par[i] = par[i-1] + age[i];
for( long long i = 1; i <= n; i ++ )
dp[i][1] = par[i];
for( long long j = 2; j <= b; j ++ )
{
for( long long i = j; i <= n; i ++ )
{
for( long long k = i; k > j-1; k -- )
{
long long x = ( dp[k-1][j-1] | ( par[i] - par[k-1] ) );
if( dp[i][j] == -1 || x < dp[i][j] ) dp[i][j] = x;
}
}
}
long long ans = -1;
for( long long i = a; i <= b; i ++ )
if( ans == -1 || dp[n][i] < ans ) ans = dp[n][i];
cout << ans << '\n';
}
int main()
{
read();
solve();
return 0;
}
/*
6 1 3
8 1 2 1 5 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
33108 KB |
Output is correct |
2 |
Incorrect |
13 ms |
33076 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
33072 KB |
Output is correct |
2 |
Incorrect |
13 ms |
33108 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
33072 KB |
Output is correct |
2 |
Incorrect |
16 ms |
33024 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
33108 KB |
Output is correct |
2 |
Incorrect |
15 ms |
33108 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
33096 KB |
Output is correct |
2 |
Incorrect |
17 ms |
33128 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |