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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n=w.size();
vector<pair<long long int,int> >mol(n);
for(int i=0;i<n;i++)mol[i]={w[i],i};
sort(mol.begin(),mol.end());
long long int ans=0,j=0;
for(int i=0;i<n;i++){
while(j<n&&mol[j].first+ans<=u){
ans+=mol[j].first;
j++;
}
//cout<<ans<<' ';
if(ans>=l){
vector<int> sol;
for(int k=i;k<j;k++)sol.push_back(mol[k].second);
return sol;
}
ans-=mol[i].first;
}
return vector<int>(0);
}
/*int main(){
vector<int> v={5,5,6,6};
int l=15,r=16;
vector<int> ans=find_subset(l,r,v);
for(int x:ans)cout<<x<<' ';
}
*/
# | 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... |