#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
long long prefix[N], suffix[N];
vector<int> find_subset(int l, int r, vector<int> w){
vector<int> ans;
int n = (int)w.size();
sort(w.begin(), w.end());
prefix[0] = w[0];
for(int i = 1; i < n; i++){
prefix[i] = prefix[i - 1] + w[i];
}
suffix[n - 1] = w[n - 1];
for(int i = n - 2; i >= 0; i--){
suffix[i] = suffix[i + 1] + w[i];
}
for(int i = 1; i <= n; i++){
if(prefix[i - 1] > r || suffix[n - i] < l){
continue;
}
for(int j = 0; j <= n - i; j++){
long long sum = prefix[j + i - 1];
if(j != 0){
sum -= prefix[j - 1];
}
if(l <= sum && sum <= r){
for(int k = 0; k < i; k++){
ans.push_back(j + k);
}
return ans;
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
3 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = YES) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
5 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
6 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
7 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
8 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
9 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
10 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
11 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
12 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [50..51] but it is 37 |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
3 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [50..51] but it is 37 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
3 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [50..51] but it is 37 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
3 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [50..51] but it is 37 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
3 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [50..51] but it is 37 |
32 |
Halted |
0 ms |
0 KB |
- |