#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;
else break;
for(int i = pivot; i < n; ++i) {
if(s >= l && s <= u) break;
if(i < n - 1) {
used[_w[i + 1].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;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
400 KB |
OK (n = 12, answer = YES) |
3 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [307..317] but it is 306 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |