# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
557055 | Ai7081 | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
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;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ret;
sort(w.begin(), w.end());
long long now = w[0];
int pl=0, pr=0;
while (pl < w.size() && pr < w.size() && (now < l || now > u)) {
if (now < l) {
if (pr+1 < w.size()) now += w[++pr];
else break;
}
if (now > u) {
if (pl < w.size()) now -= w[pl++];
else break;
}
}
if (l <= now && now <= u) {
for (int i=pl; i<=pr; i++) ret.push_back(i);
}
return ret;
}
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ret;
sort(w.begin(), w.end());
long long now = w[0];
int pl=0, pr=0;
while (pl < w.size() && pr < w.size() && (now < l || now > u)) {
if (now < l) {
if (pr+1 < w.size()) now += w[++pr];
else break;
}
if (now > u) {
if (pl < w.size()) now -= w[pl++];
else break;
}
}
if (l <= now && now <= u) {
for (int i=pl; i<=pr; i++) ret.push_back(i);
}
return ret;
}