이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef string str;
const int N = 101;
const int R = 21;
const int Y = 501;
const ll inf = 1e18;
ll y[N], pref[N];
bool dp[N][R][Y];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, a, b;
cin >> n >> a >> b;
for (int i = 1; i <= n; ++i) {
cin >> y[i];
pref[i] = pref[i - 1] + y[i];
}
for (int i = 1; i <= n; ++i) {
dp[i][1][pref[i]] = true;
}
for (int k = 2; k <= b; ++k) {
for (int i = 1; i <= n; ++i) {
for (int j = i - 1; j >= 1; --j) {
for (int x = 0; x < Y; ++x) {
if (dp[j][k - 1][x]) {
dp[i][k][x | (pref[i] - pref[j])] = true;
}
}
}
}
}
ll ans = inf;
for (int k = a; k <= b; ++k) {
for (int x = 0; x < Y; ++x) {
if (dp[n][k][x]) {
ans = min(ans, (ll)x);
}
}
}
cout << ans;
}
# | 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... |