#include "molecules.h"
#include <bits/stdc++.h>
const int MAX_N = 200000;
int N;
std::pair<int, int> W[MAX_N];
std::vector<int> find_subset(int l, int u, std::vector<int> w_in)
{
N = (int)w_in.size();
for (int i = 0; i < N; ++i)
W[i] = std::make_pair(w_in[i], i);
std::sort(std::begin(W), std::begin(W) + N);
int best_x = -1, best_y = -1, best_d = MAX_N;
for (int x = 0, y = 0, s = 0, d; x < N && y < N;) {
if (s > l) {
s -= W[x].first;
++x;
}
else {
++y;
s += W[y].first;
}
d = s - l;
if (d > 0 && d < best_d) {
best_x = x;
best_y = y;
best_d = d;
}
}
if (best_x == -1 || best_y == -1 || best_d + l > u)
return {};
std::vector<int> ret;
for (int x = best_x; x < best_y; ++x)
ret.push_back(W[x].second);
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
2 ms |
376 KB |
Contestant can not find answer, jury can |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |