# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431085 | davi_bart | Detecting Molecules (IOI16_molecules) | C++17 | 59 ms | 6796 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 "molecules.h"
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define ld long double
#define pb push_back
std::vector<int> find_subset(int l, int u, std::vector<int> p) {
vector<pair<ll,ll> > w;
for(ll i=0;i<p.size();i++)w.pb({p[i],i});
vector<int> ans;
ll tot=0;
sort(w.begin(),w.end());
reverse(w.begin(),w.end());
for(ll i=0;i<w.size();i++){
ans.pb(w[i].se);
tot+=w[i].fi;
if(tot>=l)break;
}
if(tot>=l && tot<=u)return ans;
ll pos=0;
for(ll i=w.size()-1;i>=ans.size();i--){
tot-=p[ans[pos]];
ans[pos]=w[i].se;
tot+=p[ans[pos]];
pos++;
if(pos>=ans.size())break;
if(tot<=u)break;
}
if(tot>=l && tot<=u)return ans;
ans.clear();
return ans;
/*tot=0;
sort(w.begin(),w.end());
for(int i=0;i<w.size();i++){
ans.pb(i);
tot+=w[i];
if(tot>=l)break;
}
if(tot>=l && tot<=u)return ans;
tot-=w[ans.back()];
ans.pop_back();
pos=0;
for(int i=w.size()-1;i>=ans.size();i++){
tot-=w[ans[pos]];
ans[pos]=i;
tot+=w[ans[pos]];
pos++;
if(pos>=ans.size())break;
if(tot>=l && tot<=u)break;
}
if(tot>=l && tot<=u)return ans;
ans.clear();
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... |