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 <vector>
#include <algorithm>
#include <iostream>
using namespace std;
struct molecola {
long long pos;
long long weight;
};
bool operator<(const molecola & lhs, const molecola & rhs) {
return lhs.weight<rhs.weight;
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int i, j, k, n, S=0;
vector<int> t;
n=w.size();
vector<molecola> V;
for (i=0; i<n; i++) {
V.push_back({i, w[i]});
S+=w[i];
}
if (S<l) {
cerr << "SCENARIO 1" << endl;
return t;
}
sort(V.begin(), V.end());
for (i=0; i<n; i++) {
cerr << "V[" << i << "] = {" << V[i].pos << ", " << V[i].weight << "}"<< endl;
}
i=0; S=0;
while (S<l) {
S+=V[i].weight;
i++;
}
if (S<=u) {
for (j=0; j<i; j++) {
t.push_back(V[j].pos);
}
cerr << "SCENARIO 2" << endl;
return t;
}
j=0;
i--;
S-=V[i].weight;
while (j+i<=n && S<l) {
S-=V[j].weight;
S+=V[j+i].weight;
j++;
}
if (j+i>n) {
cerr << "SCENARIO 3" << endl;
return t;
}
for (k=j; k<j+i; k++) {
t.push_back(V[k].pos);
}
cerr << "SCENARIO 4" << endl;
return t;
}
# | 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... |