#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int r, vector<int> w) {
int N = w.size();
vector<pair<int,int>> a(N);
for(int i = 0; i < N; ++i)
a[i] = make_pair(w[i], i);
sort(a.begin(), a.end());
int st = -1, dr = 0;
long long sum = 0;
for(const int &x : w)
sum += x;
while(sum < l || sum > r) {
while(sum > r) {
if(dr == N)
return {};
sum -= a[dr++].first;
}
while(sum < l) {
if(st == N - 1)
return {};
sum += a[++st].first;
}
}
if(st < 0 || dr < 0 || st >= N || dr >= N)
return {};
vector<int> sol;
for(int i = 0; i <= st; ++i)
sol.emplace_back(a[i].second);
for(int i = dr; i < N; ++i)
sol.emplace_back(a[i].second);
return sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
364 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
0 ms |
364 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
0 ms |
364 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
0 ms |
364 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
1 ms |
364 KB |
Contestant can not find answer, jury can |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
364 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
364 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
364 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
364 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |