이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 100, maxc = 8001;
int dp[51][20][maxc], n, A, B, a[maxn];
void solve()
{
cin >> n >> A >> B;
for (int i = 1; i <= n; i ++)
{
cin >> a[i];
}
dp[0][0][0] = 1;
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= B; j ++)
{
int sum = 0;
for (int k = i; k > 0; k --)
{
sum = sum + a[k];
for (int x = 0; x < maxc; x ++)
{
int new_x = (x | sum);
if (dp[k - 1][j - 1][x] == 1)
dp[i][j][new_x] = 1;
}
}
}
}
int best = maxc;
for (int j = A; j <= B; j ++)
{
for (int x = 0; x < maxc; x ++)
{
if (dp[n][j][x] != 0)
{
best = min(best, x);
break;
}
}
}
cout << best << endl;
}
int main()
{
solve();
return 0;
}
/**
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... |