이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 110;
const ll INF = (ll)1e17;
ll dp[MAXN][MAXN],soma[MAXN],vetor[MAXN],n,a,b;
ll calc(ll a,ll b){return soma[b] - soma[a-1];}
ll solve(ll pos,ll resta){
if(pos == n + 1){
if(resta == 0) return 0;
else return INF;
}
if(resta <= 0){
return INF;
}
if(dp[pos][resta] != -1) return dp[pos][resta];
ll best = INF;
for(int quebra = pos;quebra<=n;quebra++){
best = min(best, calc(pos,quebra) | solve(quebra+1,resta - 1) );
}
return dp[pos][resta] = best;
}
int main(){
memset(dp,-1,sizeof(dp));
cin >> n >> a >> b;
for(int i = 1;i<=n;i++){
cin >> vetor[i];
soma[i] = vetor[i] + soma[i-1];
}
ll best = solve(1,a);
for(int i = a+1;i<=b;i++) best = min(best, solve(1,i) );
cout << best << 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... |