#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = (int)w.size();
vector<pair<int, int>> a(n);
for (int i = 0; i < n; i++) {
a[i].first = w[i];
a[i].second = i;
}
sort(a.begin(), a.end());
vector<long long> ps(n);
ps[0] = a[0].first;
for (int i = 1; i < n; i++) {
ps[i] = ps[i - 1] + a[i].first;
}
if(*lower_bound(ps.begin(), ps.end(), l) <= u) {
vector<int> res;
for (int i = 0; i < n; i++)
{
res.push_back(i);
if(ps[i] >= l && ps[i] <= u)
break;
return res;
}
}
for (int i = 0; i < n; i++) {
auto it = lower_bound(ps.begin(), ps.end(), ps[i] + l);
if(it == ps.end())
continue;
if(*it - ps[i] <= u) {
int id = it - ps.begin();
vector<int> res;
for (int j = i + 1; j <= id; j++)
{
res.push_back(j);
}
return res;
}
}
return std::vector<int>(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [290..300] but it is 50 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |