# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
241161 | crossing0ver | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define local1
using namespace std;
const int N = 5e3+5;
int x[N],a[N*N],f[N],n,m;
int answer(int result[],deque<int> v) {
for (int i = 0; i < v.size(); i++) {
result[i] = v[i];
}
return v.size();
}
int find_subset(int l, int u, int w[], int n, int result[]) {
sort(w,w+n);
long long tot = 0;
deque<int> v;
if (w[0] > u) return 0;
for (int i = 0; i < n; i++) {
if (w[i] + tot < l) {
tot+=w[i];
v.push_back(i);
}
}
int in = v.back();
for (int i = in + 1; i < n; i++) {
if (w[i] + tot >= l && w[i] + tot <= u) {
v.push_back(i);
return answer(result,v);
}
if (w[i] + tot > u) {
tot -= w[v.front()];
v.pop_front();
tot += w[i];
v.push_back(i);
}
else {
tot += w[i];
v.push_back(i);
}
}
return 0;
}
#ifdef local
main() {
}
#endif