#include "molecules.h"
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <cassert>
#include <cstdio>
using namespace std;
typedef pair<int,int> II;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
const int N = w.size();
long long sum = 0;
vector<II> V;
for (int i = 0; i < N; ++i) {
V.push_back({w[i], i});
sum += w[i];
}
if (sum < l)
return {};
sort(V.begin(), V.end());
if (V.begin()->first > u)
return {};
vector<long long> psum(N+1);
for (int i = 1; i <= N; ++i)
psum[i] = psum[i-1] + V[i-1].first;
// fprintf(stderr, "l:%d u:%d\n", l, u);
for (int R = 1; R <= N; ++R) {
if (psum[R] < l) continue;
int L = lower_bound(psum.begin(), psum.begin()+R, psum[R]-u) - psum.begin();
// fprintf(stderr, "L:%d R:%d psum[R]:%lld\n", L, R, psum[R]);
if (psum[R] - psum[L] >= l) {
vector<int> res;
for (int i = L+1; i <= R; ++i)
res.push_back(V[i-1].second);
return res;
}
}
assert(false);
return {};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 12, answer = YES) |
3 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
1 ms |
256 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
256 KB |
OK (n = 3, answer = YES) |
13 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |