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>
using namespace std;
struct Molec {
long long int poids;
int pos;
bool operator< (Molec other) {
return poids < other.poids;
}
};
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<Molec> molecules(n);
for(int loop = 0; loop < n; ++loop) {
molecules[loop] = {w[loop], loop};
}
sort(molecules.begin(), molecules.end());
long long int somme = 0;
int fin = 0;
while(somme <= u && fin < n) {
if(somme + molecules[fin].poids <= u) {
somme += molecules[fin].poids;
fin++;
}
else {
break;
}
}
vector<int> indice;
if(l <= somme && somme <= u) {
for(int loop = 0; loop < fin; ++loop) {
indice.push_back(molecules[loop].pos);
}
return indice;
}
for(int loop = fin; loop < u; ++loop) {
somme -= molecules[loop-fin].poids;
somme += molecules[loop].poids;
if(l <= somme && somme <= u) {
for(int looping = loop-fin+1; looping <= loop; ++looping) {
indice.push_back(molecules[looping].pos);
}
return indice;
}
}
return indice;
}
# | 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... |