#include <bits/stdc++.h>
using namespace std;
mt19937 gnd(time(nullptr));
// #define int long long
vector<int> find_subset(int l, int r, vector<int> w){
int n = w.size();
vector<pair<int, int>> v(n);
for(int i = 0; i < n; i++){
v[i]={w[i], i};
}
sort(v.begin(), v.end());
int aux = 0;
vector<int> ba(n), bb(n);
for(int i = 0; i < n; i++){
ba[i]=v[i].first;
bb[i]=v[i].second;
}
vector<int> sol;
for(int i = n-1; i >= 0; i--){
if(ba[i] > r) continue;
sol.clear();
sol.push_back(bb[i]);
aux = ba[i];
bool im = 1;
int fal = l-aux;
int cp = i;
while(l > aux){
fal = r-aux;
auto it = upper_bound(ba.begin(), ba.begin()+cp, fal);
if(it == ba.end() || it == ba.begin()){
im = 0;
break;
}
else{
// if(it == ba.begin()+cp) it--;
cp = it-ba.begin()-1;
aux+=ba[cp];
sol.push_back(bb[cp]);
}
if(aux >= l && aux <= r) break;
// cp++;
if(cp == 0){
im = 0;
break;
}
}
if(im == 0) break;
if(aux <= l && aux >= r) break;
break;
}
if(aux < l || aux > r){
sol.clear();
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = YES) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
0 ms |
348 KB |
Contestant can not find answer, jury can |
21 |
Halted |
0 ms |
0 KB |
- |