#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> find_subset(int l, int u, vector<int> w) {
// idea: take advantage of the condition about being bounded above by U-L
// so for given m, it's ok to slide and take w_{i+m} - {w_i} and we'll hit in between due to IVT
int n = w.size();
vector<pair<int, int> > p(n);
for (int i=0; i<n; ++i) p[i] = {w[i], i};
sort(p.begin(), p.end());
ll lo = 0, hi = 0;
int ss = 0;
while (!(lo <= l && u <= hi)) {
if (ss == n) return vector<int>(0); // bad
lo += (ll) p[ss].first;
hi += (ll) p[n-1-ss].first;
ss++;
}
// construct possible
int next = ss;
while (lo < l) {
lo += (ll) p[next].first;
lo -= (ll) p[next-ss].first;
next++;
}
vector<int> ans(ss);
for (int i=0; i<ss; ++i) ans[i] = p[next-ss+i].second;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
10 |
Halted |
0 ms |
0 KB |
- |