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;
//#define int long long
#define double long double
#define pon ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int T=1;
#define ponchik signed main
#define pb push_back
#define pf push_front
#define endl "\n"
#define F first
#define S second
const long long N=1e5+69,INF=1e18+1488;
vector<int> find_subset(int l, int u, vector<int> w)
//int main()
{
long long n=w.size(),a=l,b=u;
// vector <long long> w;
// long long n,a,b;
// cin>>n>>a>>b;
vector <pair<long long,long long>> w1;
for (int i=0; i<n; i++)
{
// int x; cin>>x;
int x=w[i];
w1.pb({x,i});
}
sort(w1.begin(),w1.end());
long long l1=n-1,r=n,sum=0;
for (auto x:w1) sum+=x.F;
vector <int> ans;
while (l1>=-1&&r>=0)
{
if (sum<=b&&sum>=a)
{
for (int i=0; i<=l1; i++) ans.pb(w1[i].S);
for (int i=r; i<n; i++) ans.pb(w1[i].S);
break;
}
if (sum>b)
{
sum-=w1[l1].F;
l1--;
}
else if (sum<a)
{
r--;
sum+=w1[r].F;
}
}
// for (auto x:ans) cout<<x<<" ";
return ans;
}
# | 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... |