#include<bits/stdc++.h>
#include "molecules.h"
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
vector<int> find_subset(int l, int u, vector<int> w)
{
vector<pii> _w;
vector<bool> used;
vector<int> ans; ans.clear();
int n, pivot = -1, s = 0;
n = w.size(); _w.resize(n); used.resize(n, 0);
for(int i = 0; i < n; ++i) {
if(w[i] >= l && w[i] <= u) {
ans.push_back(i); return ans;
}
_w[i] = mp(w[i], i);
}
sort(_w.begin(), _w.end());
for(int i = 0; i < n; ++i)
if(s + _w[i].fi <= u) s += _w[i].fi, pivot = i, used[_w[i].se] = 1;
for(int i = pivot; i < n; ++i) {
if(s >= l && s <= u) break;
if(i < n - 1) {
used[_w[i].se] = 1;
s += (_w[i + 1].fi - _w[i - pivot].fi);
used[_w[i - pivot].se] = 0;
}
}
for(int i = 0; i < n; ++i) {
if(used[i]) ans.push_back(i);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 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 |
2 ms |
256 KB |
sum of weights should be in [302..304] but it is 251 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 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 |
2 ms |
376 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 |
2 ms |
376 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 |
2 ms |
376 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |