#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> build(multiset<int>& el, const vector<int>& w){
vector<int> sol;
for(auto i : w)if(el.count(i)){
el.erase(i);
sol.push_back(i);
}
return sol;
}
vector<int> find_subset(int l, int u, vector<int> w) {
sort(w.begin(), w.end());
long long sum = 0;
multiset<int> el;
for(auto i : w) sum += 1LL*i, el.insert(i);
while(!el.empty()){
if(sum < l) return vector<int>(0);
if(sum >= l && sum <= u) return build(el, w);
long long diff = sum - u;
auto it = el.lower_bound(diff);
if(it == el.end())
it = prev(el.end());
sum -= *it;
el.erase(it);
}
return vector<int>(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Contestant can not find answer, jury can |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |