# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
269168 | Bill_00 | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 384 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;
pair<int,int>p[200001];
std::vector<int> find_subset(int l, int u, std::vector<int> w){
int n=w.size();
for(int i=0;i<w.size();i++){
p[i]=make_pair(w[i],i);
}
sort(p,p+w.size());
vector<int>res;
int sum=0,up=-1;
for(int i=0;i<w.size();i++){
sum+=p[i].first;
if(sum<=u && sum>=l){
for(int j=0;j<=i;j++){
res.push_back(p[i].second);
}
sort(res.begin(),res.end());
return res;
}
if(sum>=l){
up=i-1;
sum-=p[i].first;
break;
}
}
if(up==-1){
return res;
}
for(int i=up;i>=0;i--){
sum-=p[i].first;
sum+=p[i+n-up-1].first;
if(sum>=l && sum<=u){
for(int j=0;j<=i-1;j++){
res.push_back(p[j].second);
}
for(int j=i+n-up-1;j<n;j++){
res.push_back(p[j].second);
}
sort(res.begin(),res.end());
return res;
}
}
return res;
}
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... |