이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[i].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... |