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 F0R(i,n) for(auto i = 0; i < (n); i++)
#define FOR(i,a,b) for(auto i = (a); i <= (b); i++)
#define ROF(i,a,b) for(auto i = (a); i >= (b); i--)
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define ll long long
using namespace std;
vi find_subset(int l,int u,vi w) {
vector<pii> a;
int n = w.size();
F0R(i,n) {
a.pb(make_pair(w[i],i));
}
sort(a.begin(),a.end());
ll pre[n];
pre[0] = a[0].F;
FOR(i,1,n-1) pre[i] = pre[i-1]+a[i].F;
vi ans;
int lo = 0, hi = n-1;
bool found = false;
while(lo <= hi && lo >= 0 && hi < n) {
ll sum = pre[hi]-pre[lo]+a[lo].F;
if(sum >= l and sum <= u) {
found = true;
break;
}
if(sum < u) lo++;
else hi--;
}
if(!found)return ans;
FOR(i,lo,hi) ans.pb(a[i].S+1);
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... |