| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 766286 | ivopav | Bali Sculptures (APIO15_sculpture) | C++17 | 1 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long int dp(long long int ind,long long int kol,long long int zbr,const vector<long long int>& lis,vector<vector<long long int>>& mem,long long int sad,long long int a,long long int b){
if (ind==lis.size()){
if (kol<a){
return numeric_limits<long long int>::max()/2;
}
if ((zbr|sad)>sad){
return numeric_limits<long long int>::max()/2;
}
return zbr;
}
if (mem[ind][kol]!=-1){
return mem[ind][kol]+zbr;
}
long long int najm=dp(ind+1,kol,zbr+lis[ind],lis,mem,sad,a,b);
if (kol!=b && (zbr|sad)<=sad && zbr!=0){
najm=min(najm,dp(ind+1,kol+1,lis[ind],lis,mem,sad,a,b));
}
mem[ind][kol]=najm-zbr;
return najm;
}
int main(){
long long int n;
long long int a;
long long int b;
cin >> n >> a >> b;
vector<long long int> lis={};
for (long long int i=0;i<n;i++){
long long int unos;
cin >> unos;
lis.push_back(unos);
}
long long int sad=numeric_limits<long long int>::max();
long long int sadznam=1<<62;
while (sadznam>0){
vector<vector<long long int>> mem=vector<vector<long long int>>(n+5,vector<long long int>(b+5,-1));
if (dp(0,1,0,lis,mem,sad-sadznam,a,b)<numeric_limits<long long int>::max()/2){
sad-=sadznam;
}
sadznam/=2;
}
cout << sad << "\n";
}Compilation message (stderr)
| # | 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... | ||||
