#include "molecules.h"
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define ll long long
using namespace std;
pair<int,int>p[200002];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n=w.size();
for(int i=1;i<=n;i++){
p[i]=mp(w[i-1],i-1);
}
sort(p+1,p+n+1);
vector<int>res;
ll sum=0,id=0;
for(int i=1;i<=n;i++){
sum+=p[i-1].ff;
if(sum>=l && sum<=u){
for(int j=1;j<=i;j++){
res.push_back(p[i-1].ss);
}
return res;
}
if(sum>=l){
sum-=p[i-1].ff;
id=i-1;
break;
}
}
//cout << id << endl;
if(id==0){
return res;
}
for(int i=id;i>=1;i--){
sum=sum-p[i-1].ff;
sum=sum+p[i+n-id-1].ff;
//cout << sum << endl;
if(sum>=l){
for(int j=1;j<i;j++){
res.push_back(p[j-1].ss);
}
for(int j=i+n-id;j<=n;j++){
res.push_back(p[j-1].ss);
}
return res;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
384 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
item #0 is taken twice |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
384 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
384 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
384 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
384 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |