# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
566526 | ac2hu | Bali Sculptures (APIO15_sculpture) | C++14 | 1087 ms | 3008 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>
#ifdef DEBUG
#include "../templates/debug.h"
#else
#define deb(x...)
#endif
using namespace std;
#define int long long
struct bag : set<pair<int,int>>{
void add(int n, int temp){
for(auto it = begin();it!=end();++it){
auto [e, val] = *it;
if(((e&n) == e) && temp >= val)return;
}
insert({n, temp});
}
};
signed main() {
iostream::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int n, a, b;cin >> n >> a >> b;
vector<int> Y(n);
for(auto &e : Y)cin >> e;
bag dp[n + 1];
dp[0].add(0, 0);
for(int i = 1;i<=n;i++){
int tsum = 0;
for(int j = i;j>=1;j--){
tsum += Y[j - 1];
if(dp[j - 1].size() != 0){
for(auto [e, val] : dp[j - 1]){
if(val < b){
dp[i].add(e|tsum, val + 1);
}
}
}
}
}
deb(dp[n]);
cout << (*dp[n].begin()).first << "\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... |