#include <bits/stdc++.h>
#define N 2005
using namespace std;
typedef long long ll;
int n, A, B, v[N];
ll dp[N][N], sum[N], ans = 200000000000000000LL;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>A>>B;
for(int i = 1; i <= n; i++) cin>>v[i], sum[i] = sum[i - 1] + (ll)v[i], dp[i][1] = sum[i];
for(int k = 2; k <= B; k++)
{
for(int i = 1; i <= n; i++)
{
dp[i][k] = 200000000000000000LL;
for(int j = 1; j <= i; j++)
{
if(j < k - 1) continue;
dp[i][k] = min( (dp[j - 1][k - 1] | (sum[i] - sum[j - 1])), dp[i][k]);
//cout<<dp[j - 1][k - 1]<<" "<<(sum[i] - sum[j - 1])<<" "<<(dp[j - 1][k - 1] | (sum[i] - sum[j - 1]))<<"\n";
}
if(A <= k && k <= B && i == n) ans = min(ans, dp[i][k]);
//cout<<i<<" "<<k<<" "<<dp[i][k]<<"\n";
}
}
cout<<ans<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
404 KB |
Output is correct |
2 |
Incorrect |
1 ms |
404 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
404 KB |
Output is correct |
2 |
Incorrect |
1 ms |
456 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |