이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
int n, a, b;
int cost[2100];
bool dp[60][30][600];
int main () {
cin >> n >> a >> b;
for (int i=1; i<=n; i++) {
cin >> cost[i];
}
cost[0] = 0;
dp[0][0][0] = true;
for (int i=1; i<=n; i++) {
for (int j=1; j<=b; j++) {
int cursum = cost[i];
for (int k=i-1; k>=0; k--) {
for (int l=0; l<600; l++) {
if (dp[k][j-1][l]) dp[i][j][l|cursum] = true;
}
cursum += cost[k];
}
}
}
int ans = 1e9;
for (int i=a; i<=b; i++) {
for (int j=0; j<600; j++) {
if (dp[n][i][j]) {
ans = min(ans, j);
if (j == 9) cout << i << endl;
}
}
}
cout << ans << endl;
}
/*
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... |