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 ll long long
using namespace std;
ll n,m,k,x,y,z;
ll a,b;
bool dp[105][2005][105];
ll ar[105];
signed main() {
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) cin >> ar[i];
ll mxval = 0;
for (int i = 1; i <= n; i++) mxval = max(mxval,ar[i]);
for (int i = 1; i <= n; i++) ar[i] += ar[i-1];
dp[0][0][0] = 1;
for (int i = 1; i <= n; i++) { //pos
for (int j = 1; j <= n; j++) { //st pos
for (int k = 1; k <= n; k++) { //groups
for (int l = 0; l <= n*mxval; l++) { //total or
if (dp[j-1][l][k-1]) dp[i][l|(ar[i]-ar[j-1])][k] = 1;
}
}
}
}
for (int i = 0; i <= mxval*n; i++) {
for (int j = a; j <= b; j++) {
if (dp[n][i][j]) {
cout << i << "\n";
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... |