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 <bits/stdc++.h>
#include "molecules.h"
#define endl '\n'
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
vector<int> find_subset(int l,int u,vector<int> w)
{
int n=w.size();
vector<pair<int,int>> ww;
vector<ll> ssum;
for(int i=0; i<n; i++) ww.push_back({w[i],i});
sort(ww.begin(),ww.end());
ll sum=0;
for(int i=0; i<n; i++)
{
sum+=ww[i].F;
ssum.push_back(sum);
}
ll idx=0;
while(idx<n && ssum[idx]<l) ++idx;
if(idx<n && ssum[idx]<=u)
{
vector<int> result;
for(int i=0; i<=idx; i++) result.push_back(ww[i].S);
return result;
}
for(int i=0; i<n; i++)
{
while(idx<n && ssum[idx]-ssum[i]<l) ++idx;
if(idx<n && ssum[idx]-ssum[i]<=u)
{
vector<int> result;
for(int j=0; j<=idx; j++) result.push_back(ww[j].S);
return result;
}
}
return vector<int> ();
}
/*
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,l,u;
cin>>n>>l>>u;
vector<int> w(n);
for(int i=0; i<n; i++) cin>>w[i];
vector<int> result=find_subset(l,u,w);
cout<<(int)result.size()<<endl;
for(int i=0; i<(int)result.size(); i++) cout<<result[i]<<' ';
return 0;
}
*/
# | 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... |