# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1217092 | moondarkside | Detecting Molecules (IOI16_molecules) | C++20 | 34 ms | 4276 KiB |
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> find_subset( int l, int u, vector<int> w ) {
vector<pair<int,int>> Sorted;
for(int i=0;i<w.size();i++){
Sorted.push_back({w[i],i});
}
sort(Sorted.begin(),Sorted.end());
if(Sorted[0].first>u){
return vector<int>();
}
int weight=0;
std::queue<int> Solution;
for(int i=0;i<Sorted.size();i++){
Solution.push(i);
weight+=Sorted[i].first;
if(weight>=l && weight<=u){
vector<int> Sol;
while(!Solution.empty()){
Sol.push_back(Sorted[Solution.front()].second);
Solution.pop();
}
return Sol;
}
while (weight > u && !Solution.empty()) {
weight -= Sorted[Solution.front()].first;
Solution.pop();
}
if(weight>=l && weight<=u){
vector<int> Sol;
while(!Solution.empty()){
Sol.push_back(Sorted[Solution.front()].second);
Solution.pop();
}
return Sol;
}
}
return vector<int>();
}
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... |