# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
488754 | ala2 | Detecting Molecules (IOI16_molecules) | C++14 | 2 ms | 3404 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, vector<int> w) {
pair<long long,int>p[200010];
int n=w.size();
for(int i=0;i<n;i++)
{
p[i].first=w[i];
p[i].second=i;
}
sort(p,p+n);
int ll=0,rr=0;
long long sum=p[0].first;
int bb=0;
while(ll<=rr&&ll<n&&rr<n)
{
// <<ll<<" "<<rr<<endl;
if(sum>u&&ll==rr)
bb=1;
if(sum>u)
{
ll++;
sum-=p[ll-1].first;
}
if(sum>=l&&sum<=u)
{
break;
}
if(sum<l)
{
rr++;
sum+=p[rr].first;
}
}
vector<int>g;
if(sum<l)
bb=1;
if(bb)
{
ll=1;
rr=0;
}
for(int i=ll;i<=rr;i++)
g.push_back(p[i].second+1);
sort(g.begin(),g.end());
return g;
}
//15 25
//4 10 10 10 11
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... |