#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ans={};
int n=w.size(),sum=0,m=0,k,p,x=0;
for(int i=0;i<n;i++) sum+=w[i];
if(sum<l) return {};
sort(w.begin(),w.end());
sum=0;
for(int i=0;i<n;i++){
if(sum+w[i]>u) break;
sum+=w[i];
m=i+1;
}
if(m==0) return {};
k=n-1;
p=0;
while(sum<l){
if(k<m || p==m) break;
x++;
sum+=w[k];
sum-=w[p];
k--;
p++;
}
if(sum<l) return {};
for(int i=x;i<m;i++) ans.push_back(w[i]);
for(int i=n-1;i>=n-x;i--) ans.push_back(w[i]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
436 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Integer 50 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 |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
436 KB |
Integer 10 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 |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
436 KB |
Integer 10 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 |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
436 KB |
Integer 10 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 |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
436 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |