#include "molecules.h"
#include "bits/stdc++.h"
std::vector<int> find_subset(int a, int b, std::vector<int> w) {
sort(w.begin(),w.end());
int n = w.size();
int resr = -1,resl = -1;
int l = 0;
int ans = 0;
int sum = 0;
for(int r = 0;r < n;r++) {
sum += w[r];
if(sum < a) {
continue;
}
while(sum > b && l <= r) {
sum -= w[l];
l++;
}
if(sum >= a && sum <= b) {
if(ans < r - l + 1) {
ans = r - l + 1;
resr = r,resl = l;
}
}
}
std::vector<int> res;
if(resr == -1) return res;
for(int i = resl;i <= resr;i++) {
res.push_back(w[i]);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Integer 50 violates the range [0, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |