# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31062 | platinant | Detecting Molecules (IOI16_molecules) | C++14 | 56 ms | 5068 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 <algorithm>
using namespace std;
typedef pair<int,int> pp;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ret;
vector<pp> a(w.size());
for(int i=0;i<w.size();i++){
a[i]=pp(w[i],i);
}
sort(a.begin(),a.end());
int len=0,sum=0;
while(len<a.size()&&sum<l){
sum+=a[len].first;
len++;
}
if(sum>=l&&sum<=u){
for(int i=0;i<len;i++)ret.push_back(a[i].second);
return ret;
}
for(int i=len,j;i<=w.size();i++){
j=i-len+1;
sum-=a[j-1].first;
if(sum>=l){
for(int k=j;k<i;k++)ret.push_back(a[k].second);
return ret;
}
if(i<w.size())sum+=a[i].first;
}
return ret;
}
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... |