# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1211841 | Marco_Escandon | Detecting Molecules (IOI16_molecules) | C++20 | 0 ms | 328 KiB |
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
sort(w.begin(),w.end());
ll ac=0;
vector<ll> ans;
priority_queue<pair<ll,ll>> q;
for(int i=0; i<w.size(); i++)
{
if(ac+w[i]<=u)
{
ac+=w[i];
ans.push_back(i);
if(ac>=l) return ans;
}
else q.push({w[i],i});
}
ll p=0;
while(p<ans.size()&&!q.empty()&&ac<=l&&q.top().first>w[ans[p]])
{
ac+=q.top().first-w[ans[p]];
q.push({w[ans[p]],ans[p]});
ans[p]=q.top().second;
p++;
q.pop();
}
if(ac>=l&&ac<=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... |