#include "molecules.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
vector<int> find_subset(int l, int u, vector<int> w) {
vector<pair<ll, int>> new_w;
vector<int> bl;
int n = w.size();
ll tot_sum = 0;
for(int i = 0; i < n; i++){
tot_sum += w[i];
new_w.push_back({w[i], i});
}
sort(new_w.begin(), new_w.end());
ll currsum = 0;
int s = 0;
for(int i = 0; i < n; i++){
currsum += new_w[i].first;
while(currsum > u && s <= i){
currsum -= new_w[s].first;
s++;
}
if(currsum >= l && currsum <= u){
vector<int> res;
for(int x = s; x <= i; x++)
res.push_back(new_w[i].second);
return res;
}
}
return bl;
}
/*int main(){
int n, l, u;
vector<int> niz;
cin >> n >> l >> u;
niz.resize(n);
for(int i = 0; i < n; i++)
cin >> niz[i];
vector<int> rs = find_subset(l, u, niz);
for(int i = 0; i < rs.size(); i++)
cout << rs[i] << endl;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
item #7 is taken twice |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |