# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
501451 | MurotY | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 204 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>
#define ll long long
#define ff first
#define ss second
#include "molecules.h"
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector <pair <ll,ll> > a(w.size()+1);
map <ll,ll> mp;
ll sum=0;
for (int i=0;i<w.size();i++) a[i+1].ff=w[i], a[i].ss=i,sum+=w[i], mp[w[i]]++;
int n=w.size()+1;
// sort(a+1,a+n+1);
vector <ll> dp(sum+1, 0);
vector <ll> v[sum+1];
dp[0]=1;
for (int i=1;i<=n;i++) v[a[i].ff].push_back(a[i].ss);
for (int i=1;i<=n;i++){
for (int j=sum;j>=0;j--){
if (a[i].ff+j <= sum and dp[a[i].ff+j] == 0){
dp[a[i].ff+j] |= dp[j];
if (dp[a[i].ff+j] and mp[a[i].ff+j] == 0) {
for (auto it:v[j]) v[j+a[i].ff].push_back(it);
if (j != 0) for (auto it:v[a[i].ff]) v[j+a[i].ff].push_back(it);
}
}
}
}
ll jv=-1, res=1e9;
for (int i=l;i<=sum;i++){
if (i > u) break;
if (dp[i]){
if (res > v[i].size()){
res=v[i].size();
jv=i;
}
}
}
vector <int> ans;
if (jv == -1);
else for (auto l:v[jv]) ans.push_back(l);
return ans;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |