#include "molecules.h"
#include <cassert>
#include <algorithm>
using ll = long long;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int N = w.size();
std::vector<int> o(N);
for(int i = 0;i < N;++i) o[i] = i;
std::sort(o.begin(), o.end(), [&](int a, int b){return w[a]<w[b];});
std::sort(w.begin(), w.end());
std::vector<ll> vl(N, 0), vr(N, 0);
for(int i = 0;i < N;++i)
vl[i] = w[i] + (i ? vl[i-1] : 0LL);
for(int i = 0;i < N;++i)
vr[i] = w[N-i-1] + (i ? vr[i-1] : 0LL);
for(int i = 0;i < N;++i)
if(vl[i] <= u && l <= vr[i])
{
//answer
ll s = vl[i];
int j = i;
for(;j >= 0 && s < l;--j) s += w[N-i-1+j] - w[j];
std::vector<int> ans(0);
for(int k = 0;k <= j;++k) ans.push_back(o[k]+1);
for(int k = N-i+j;k < N;++k) ans.push_back(o[k]+1);
return ans;
}
return std::vector<int>(0);
}
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
4 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Integer 12 violates the range [0, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
4 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
4 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
4 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
4 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |