This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define f(i,j,n) for(ll i = j; i < n; ++i)
#define fd(i,j,n) for(i = j; i < n; ++i)
#define fr(i,j,n) for(ll i = j; i >= n; --i)
#define sz(v) (ll) v.size()
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
const int N = 2e3 + 50;
const int M = 1e6 + 20;
const ll mod = 998244353;
const ll inf = 1e14;
ll n,a,b,y[N];
void solve1(){
ll dp[105][105];
ll k = b;
f(i,0,n+1){
f(j,0,k+1) dp[i][j] = inf;
}
dp[0][1] = 0;
f(i,1,n+1) dp[i][1] = dp[i-1][1]+y[i];
f(j,2,k+1){
f(i,j,n+1){
ll lg = y[i];
fr(r,i-1,j-1){
dp[i][j] = min(dp[i][j],dp[r][j-1]|lg);
lg += y[r];
}
}
}
ll ans = inf;
f(i,a,b+1) ans = min(dp[n][i],ans);
cout << ans << endl;
}
void solve(){
cin >> n >> a >> b;
f(i,1,n+1) cin >> y[i];
if(n <= 100){
solve1();
}
}
int main(){
ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
int tc = 1;
// cin >> tc;
while(tc--) solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |