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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
ll n, a, b, x[2001], dp[2001][2001], ans = 1e18;
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> a >> b;
for (int i = 1; i <= n; i++)
{
cin >> x[i];
x[i] += x[i - 1];
dp[1][i] = x[i];
}
for (int i = 2; i <= b; i++)
for (int j = 1; j <= n; j++)
dp[i][j] = 1e18;
for (int i = 2; i <= b; i++)
for (int j = 1; j <= n; j++)
for (int k = i - 1; k < j; k++)
dp[i][j] = min(dp[i][j], (dp[i - 1][k] | (x[j] - x[k])));
for (int i = a; i <= b; i++)
ans = min(ans, dp[i][n]);
cout << ans;
}
/*
6 1 3
8 1 2 1 5 4
*/
# | 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... |