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 double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<double> point;
void debug_out(){cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cerr << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 2e5 + 10;
int n, a[maxn], idx[maxn];
bool cmp(int x, int y){
return a[x] < a[y];
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int> ans;
n = w.size();
for (int i = 0; i < n; i++){
a[i] = w[i];
idx[i] = i;
}
sort(idx, idx + n, cmp);
ll sum = 0;
int ptr = 0;
for (int i = 0; i < n; i++){
sum += a[idx[i]];
while (sum > u){
sum -= a[idx[ptr]];
ptr++;
}
if (sum < l) continue;
for (int j = ptr; j <= i; j++) ans.push_back(idx[j]);
break;
}
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... |