#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define setp fixed<<setprecision
#define OK cerr<<"OK"<<endl<<flush
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define y0 jahdakdh
#define y1 jahsadakdakdh
#define endl '\n'
const ll MOD=1e9+7;
const ll mod=(1ll<<31)-1;
const ld eps=1e-8;
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
ll n, a, b, dp[2005][2005], pr[2005], ans;
int main()
{
SPEED;
memset(dp, 63, sizeof(dp));
ans=MOD*MOD;
cin>>n>>a>>b;
for(int i=1; i<=n; i++)
{
ll x;
cin>>x;
pr[i]=pr[i-1]+x;
dp[i][1]=pr[i];
}
for(int i=1; i<=n; i++)
{
for(int j=2; j<=i; j++)
{
for(int k=1; k<i; k++)
{
dp[i][j]=min(dp[i][j], dp[k][j-1]|(pr[i]-pr[k]));
// cout<<i<<' '<<j<<' '<<k <<' '<<dp[i][j]<<endl;
}
}
}
for(int i=a; i<=b; i++)
ans=min(ans, dp[n][i]);
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
31700 KB |
Output is correct |
2 |
Incorrect |
13 ms |
31700 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
31700 KB |
Output is correct |
2 |
Incorrect |
13 ms |
31780 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
31728 KB |
Output is correct |
2 |
Incorrect |
14 ms |
31804 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
31700 KB |
Output is correct |
2 |
Incorrect |
16 ms |
31736 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
31700 KB |
Output is correct |
2 |
Incorrect |
14 ms |
31692 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |