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;
typedef long long ll;
typedef vector<int> vi;
#define REP(i,a,b) for(int i=a;i<b;i++)
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n=w.size();
vector<pair<int,int>> arr(n);
REP(i,0,n){
arr[i].first=w[i];
arr[i].second=i;
}
sort(arr.begin(),arr.end());
ll sum=0;
int a=0,b=0;
int a1=a;int b1=b;
sum+=(ll)arr[0].first;
while(b<n){
while(b+1<n&&sum<l){
b++;
sum+=(ll)arr[b].first;
}
while(a<b&&sum>u){
sum-=(ll)arr[a].first;
a++;
}
if(sum>=l&&sum<=u)break;
if(b==n-1&&a+1==b)return std::vector<int>(0);
if(b==b1&&a==a1)return std::vector<int>(0);
a1=a;b1=b;
}
vi ans;
REP(i,a,b+1)ans.push_back(arr[i].second);
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... |