이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define lli int
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define num first
#define id second
lli ult,sum,cont,n;
lli visitados[200002];
vector<lli> res;
vector<pair<lli,lli> > orden;
vector<int> procesa(){
rep(i,0,n-1) if (visitados[i] > 0) res.push_back(i);
return res;
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
cont = 0;
for (auto act : w) {
orden.push_back({act,cont});
cont++;
}
sort(orden.begin(), orden.end());
ult = -1;
cont = 0;
sum = 0;
n = w.size();
for (auto act : orden) {
sum += act.num;
if (sum > u) {
ult = cont-1;
sum -= act.num;
break;
}
visitados[act.id] = 1;
cont++;
}
if (sum <= u && sum >= l) procesa();
if (ult == -1) return {};
cont = ult;
repa(i,n-1,n-cont-1) {
sum -= orden[ult].num;
visitados[ orden[ult].id ] = 0;
sum += orden[i].num;
visitados[ orden[i].id ] = 1;
ult--;
if (sum <= u && sum >= l) return procesa();
}
return {};
}
# | 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... |