#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
struct mol{
int loc;
long long val;
bool operator<(const mol& rhs) const{
return val <= rhs.val;
}
};
vector<mol> v;
vector<long long> s;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int i, n = w.size();
mol tmp;
for( i = 0; i < n; i++){
tmp.loc = i;
tmp.val = w[i];
v.push_back(tmp);
}
sort(v.begin(), v.end());
s.push_back(0LL);
for(i = 0; i < n; i++){
s.push_back(s[i] + (long long)v[i].val);
}
for( i = 1;i <=n ; i++){
if(s[i ] > (long long)u){
break;
}
if(s[n] - s[ n - i] >= (long long)l){
break;
}
}
if(s[i] > (long long)u || i == n + 1){
return std::vector<int>(0);
}
vector<int> ans;
int j;
if(n == i){
for(i = i - 1; i >= 0 ; i--){
ans.push_back(v[i].loc);
}
return ans;
}
for( j = 1; i>0 ;j++){
if(n - j == i -1){
for(i = i - 1; i >= 0 ; i--){
ans.push_back(v[i].loc);
}
break;
}
if(s[n - j] - s[n - i -j] < (long long)l){
ans.push_back(v[n - j].loc);
l -= v[n - j].val;
i--;
if(i == 0){
break;
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
516 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
3 ms |
516 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
18 |
Runtime error |
4 ms |
1004 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1004 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
1004 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
2 ms |
1004 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
3 ms |
1004 KB |
OK (n = 12, answer = NO) |
5 |
Correct |
3 ms |
1004 KB |
OK (n = 12, answer = YES) |
6 |
Correct |
3 ms |
1004 KB |
OK (n = 12, answer = YES) |
7 |
Correct |
3 ms |
1004 KB |
OK (n = 12, answer = YES) |
8 |
Correct |
2 ms |
1004 KB |
OK (n = 12, answer = YES) |
9 |
Correct |
3 ms |
1004 KB |
OK (n = 6, answer = YES) |
10 |
Correct |
3 ms |
1004 KB |
OK (n = 12, answer = YES) |
11 |
Runtime error |
3 ms |
1004 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
516 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
3 ms |
516 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
18 |
Runtime error |
4 ms |
1004 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
516 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
3 ms |
516 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
18 |
Runtime error |
4 ms |
1004 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
516 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
3 ms |
516 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
18 |
Runtime error |
4 ms |
1004 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
516 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
3 ms |
516 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
3 ms |
516 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
3 ms |
644 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
644 KB |
OK (n = 3, answer = NO) |
18 |
Runtime error |
4 ms |
1004 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |