#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define fastio ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const ll N = 2020;
const ll MOD = 1e9+7;
ll dp[N][N];
int main()
{
fastio;
ll n,a,b;
cin >> n >>a >> b;
ll arr[N];
ll pre[N];
for(int i = 1;i<=n;i++) cin >> arr[i];
pre[0] = 0;
pre[1] = arr[1]; for(int i =2;i<=n;i+=1) pre[i] = pre[i-1] + arr[i];
for(int i=0;i<N;i++)
for(int j =0;j<N;j++)
dp[i][j] = LLONG_MAX;
for(int i= 1;i<=n;i++)
{
dp[i][1] = pre[i];
for(int x = 2;x<=i;x++)
{
for(int l = 1;l<i;l++)
{
dp[i][x] = min((dp[l][x-1] | (pre[i]-pre[l])),dp[i][x]);
}
}
}
ll ans =LLONG_MAX;
for(int i=a;i<=b;i++)
{
ans=min(ans,dp[n][i]);
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
32220 KB |
Output is correct |
2 |
Incorrect |
28 ms |
32248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
32248 KB |
Output is correct |
2 |
Incorrect |
33 ms |
32248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
32248 KB |
Output is correct |
2 |
Incorrect |
29 ms |
32252 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
32248 KB |
Output is correct |
2 |
Incorrect |
28 ms |
32248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
32248 KB |
Output is correct |
2 |
Incorrect |
29 ms |
32340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |