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;
struct datos{
int valor;
int id;
};
const bool operator <(const datos&a, const datos&b){
return a.valor < b.valor;
}
datos arre[200005];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int tam = w.size();
for (int i = 0; i < tam; i++){
arre[i].valor = w[i];
arre[i].id = i;
}
sort(arre + 0, arre + tam);
int ini = 0, fin = 0, mayor, menor;
long long int suma = 0;
if (l > u){
mayor = l;
menor = u;
}else{
mayor = u;
menor = l;
}
bool puede = false;
while (fin <= tam){
if (suma < menor){
suma += arre[fin].valor;
fin++;
}else{
if (suma > mayor){
suma -= arre[ini].valor;
ini++;
}else{
if (suma >= menor and suma <= mayor){
puede = true;
break;
}
}
}
}
vector <int> res;
if (puede){
suma = 0;
for (int i = ini; i <= fin; i++){
if (suma < menor){
res.push_back(arre[i].id);
suma += arre[i].valor;
}
}
}
return res;
}
# | 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... |