#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> find_subset(int l, int u, vector<int> wx) {
ll n = wx.size();
vector<ll> minval(n);
vector<ll> maxval(n);
vector<pair<int,int>> w(n);
for (int i = 0; i<n; i++){
w[i]={wx[i],i};
}
sort(w.begin(),w.end());
ll curmin = 0;
ll curmax = 0;
for (int i = 0; i<n; i++){
curmin+=w[i].first;
curmax+=w[n-1-i].first;
minval[i]=curmin;
maxval[i]=curmax;
}
/*for (int i = 0; i<n; i++){
cout<<minval[i]<<' '<<maxval[i]<<'\n';
}*/
for (int i = 0; i<n; i++){
if (l<=minval[i]&&minval[i]<=u){
vector<int> ans(i+1);
for (int x = 0; x<=i; x++){
ans[x]=w[x].second;
}
assert(ans.size()>0);
return ans;
} else if (l<=maxval[i]&&maxval[i]<=u){
vector<int> ans(i+1);
for (int x = n-1; x>=n-1-i; x--){
ans[n-1-x]=w[x].second;
}
assert(ans.size()>0);
return ans;
} else if (l<=minval[i]&&maxval[i]<=u){
int lptr = i;
int rptr = n-1;
ll s = minval[i];
while (!(l<=s&&s<=u)){
s-=w[lptr].first;
s+=w[rptr].first;
lptr--;
rptr--;
}
vector<int> ans;
for (int i = 0; i<=lptr; i++){
ans.push_back(w[i].second);
}
for (int i = rptr+1; i<n; i++){
ans.push_back(w[i].second);
}
assert(ans.size()>0);
return ans;
} else {
assert(maxval[i]<l||u<minval[i]);
}
}
return vector<int>(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
256 KB |
OK (n = 100, answer = YES) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
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 |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
256 KB |
OK (n = 100, answer = YES) |
20 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
256 KB |
OK (n = 100, answer = YES) |
20 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
256 KB |
OK (n = 100, answer = YES) |
20 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
256 KB |
OK (n = 100, answer = YES) |
20 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
21 |
Halted |
0 ms |
0 KB |
- |