#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w)
{
const size_t n = w.size();
vector<pair<int, size_t>> v;
for(size_t i = 0; i < n; i++)
v.emplace_back(w[i], i);
sort(v.begin(), v.end());
sort(w.begin(), w.end());
int a = w[0];
for(auto& x : w)
x -= a;
vector<int64_t> s(n + 1), z(n + 1);
for(size_t i = 0; i < n; i++)
s[i+1] = s[i] + w[i], z[i+1] = z[i] + w[n-i-1];
vector<int> result;
for(size_t k = 1; result.empty() and k <= n; k++)
{
size_t lo = 0, hi = k;
auto c = [&](size_t i) {
return (int64_t)k*a + s[k-i] + z[i];
};
while(lo < hi)
{
auto mid = (lo + hi) / 2;
if(c(mid) >= l)
hi = mid;
else
lo = mid+1;
}
if(lo <= k and l <= c(lo) and c(lo) <= u)
{
result.reserve(k);
copy(w.begin(), w.begin() + lo, back_inserter(result));
copy(w.end() - (k-lo), w.end(), back_inserter(result));
break;
}
}
for(auto& x : result)
x += a;
vector<int> ind; ind.reserve(result.size());
for(size_t i = 0, j = 0; i < n and j < result.size(); i++)
if(v[i].first == result[j])
ind.push_back(v[i].second), j++;
return ind;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
5 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
4 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
5 ms |
384 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
4 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
5 ms |
384 KB |
OK (n = 100, answer = YES) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
4 ms |
256 KB |
sum of weights should be in [290..300] but it is 306 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
5 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
4 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
5 ms |
384 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
4 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
5 ms |
384 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = NO) |
24 |
Incorrect |
4 ms |
256 KB |
sum of weights should be in [290..300] but it is 306 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
5 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
4 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
5 ms |
384 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
4 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
5 ms |
384 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = NO) |
24 |
Incorrect |
4 ms |
256 KB |
sum of weights should be in [290..300] but it is 306 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
5 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
4 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
5 ms |
384 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
4 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
5 ms |
384 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = NO) |
24 |
Incorrect |
4 ms |
256 KB |
sum of weights should be in [290..300] but it is 306 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
5 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
4 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
5 ms |
384 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
5 ms |
256 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
4 ms |
384 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
4 ms |
256 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
4 ms |
256 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
5 ms |
384 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
4 ms |
256 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
5 ms |
256 KB |
OK (n = 12, answer = NO) |
24 |
Incorrect |
4 ms |
256 KB |
sum of weights should be in [290..300] but it is 306 |
25 |
Halted |
0 ms |
0 KB |
- |