# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61091 | Tenuun | Detecting Molecules (IOI16_molecules) | C++17 | 4 ms | 672 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"
#include<bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, std::vector<int> w) {
deque<int>res;
vector<int>ans;
vector<pair<int, int> >v;
for(int i=0; i<w.size(); i++){
v.push_back({w[i], i});
}
sort(v.rbegin(), v.rend());
long long curr=0;
int L=0, r=0;
while(L<v.size()){
r=max(r, L);
if(L==r){
curr=v[L].first;
res.clear();
res.push_back(v[L].second);
}
while(r+1<v.size() && curr<l){
curr+=v[r+1].first;
res.push_back(v[r+1].second);
r++;
}
if(curr>=l && curr<=u){
while(!res.empty()){
ans.push_back(res.front());
res.pop_front();
}
return ans;
}
while(!res.empty() && curr>u){
curr-=v[L].first;
res.pop_front();
L++;
}
if(curr>=l && curr<=u){
while(!res.empty()){
ans.push_back(res.front());
res.pop_front();
}
return ans;
}
L++;
}
if(curr>=l && curr<=u){
while(!res.empty()){
ans.push_back(res.front());
res.pop_front();
}
return ans;
}
else 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... |