이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
typedef long double ld;
using namespace std;
int n, a, b;
ll num[2005], pre[2050];
ll dp[2005][2005];
ll c(int i, int j) {
return pre[j] - pre[i-1];
}
int main()
{
cin >> n >> a >> b;
ll mn = 1e18+7;
for(int i = 1; i <= n; i++) cin >> num[i];
for(int i = 1; i <= n; i++) pre[i] = pre[i-1] + num[i];
for(int p = a; p <= b; p++) {
for(int i = 1; i <= n; i++) dp[1][i] = pre[i];
for(int k = 2; k <= p; k++) {
for(int i = 1; i <= n; i++) {
dp[k][i] = 1e18+7;
for(int j = 1; j < i; j++) {
dp[k][i] = min(dp[k][i], dp[k-1][j] | c(j+1, i));
}
}
}
mn = min(mn, dp[p][n]);
}
cout << mn << endl;
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... |