#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<signed> find_subset(signed l, signed u, vector<signed> w) {
int n = w.size(), r = u;
vector<pair<int, int>> vec;
for (int i=0; i<n; i++) {
int k = w[i];
vec.push_back({k, i});
}
sort(vec.begin(), vec.end());
int mi = 0, ma = 0, li = 0, ri = n - 1;
while (li < n) {
mi += vec[li].first, ma += vec[ri].first;
if (l <= mi && mi <= r) {
vector<signed> ans;
for (int i=0; i<=li; i++) ans.push_back(vec[i].second);
return ans;
}
if (l <= ma && ma <= r) {
vector<signed> ans;
for (int i=ri; i<n; i++) ans.push_back(vec[i].second);
return ans;
}
if (mi <= l && r <= ma) {
int sum = mi - vec[li].first;
for (int i=li; i<n; i++) {
sum += vec[i].first;
if (l <= sum && sum <= r) {
vector<signed> ans;
for (int j=i-li; j<=i; j++) ans.push_back(vec[i].second);
return ans;
}
sum -= vec[i-li].first;
}
}
li++, ri--;
}
return {};
}
# |
결과 |
실행 시간 |
메모리 |
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 |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 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 |
0 ms |
436 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
432 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
348 KB |
OK (n = 100, answer = YES) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
item #7 is taken twice |
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 |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 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 |
0 ms |
436 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
432 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
348 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
344 KB |
item #7 is taken twice |
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 |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 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 |
0 ms |
436 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
432 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
348 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
344 KB |
item #7 is taken twice |
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 |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 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 |
0 ms |
436 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
432 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
348 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
344 KB |
item #7 is taken twice |
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 |
0 ms |
348 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 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 |
0 ms |
436 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
1 ms |
344 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
432 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
348 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
344 KB |
item #7 is taken twice |
21 |
Halted |
0 ms |
0 KB |
- |