#include "molecules.h"
#define fi first
#define se second
#include <bits/stdc++.h>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
vector<pair<int, int>> s;
for (int i = 0; i < n; i++) {
s.push_back(make_pair(w[i], i+1));
}
sort(s.begin(), s.end());
vector<int> sp (n, 0);
vector<int> ss (n, 0);
sp[0] = s[0].fi;
ss[n-1] = s[n-1].fi;
for (int i = 1; i < n; i++) {
sp[i] = sp[i-1]+s[i].fi;
ss[n-1-i] = ss[n-i]+s[n-1-i].fi;
}
for (int i = 0; i < n; i++) {
if (sp[i] <= u && ss[n-1-i] >= l) {
vector<int> v;
int sum = 0;
for (int j = 0; j <= i; j++) {
v.push_back(s[j].se);
sum += s[j].fi;
}
for (int j = 0; j <= i; j++) {
if (sum < l) {
sum -= s[j].fi;
sum += s[n-1-j].fi;
v[j] = s[n-1-j].se;
}
}
return v;
}
}
return vector<int>(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Integer 12 violates the range [0, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |