#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
vector< pair<lld, lld> > L;
lld fr[200002];
lld bk[200002];
vector<int> find_subset(int l, int u, vector<int> w) {
int N = w.size();
for (int i=0; i<N; i++){
L.push_back(make_pair(w[i], i));
}
sort(L.begin(), L.end());
for (int i=0; i<N; i++){
if (i == 0){
fr[i] = L[i].first;
bk[i] = L[N-i-1].first;
continue;
}
else{
fr[i] = fr[i-1] + L[i].first;
bk[i] = bk[i-1] + L[N-i-1].first;
}
}
vector<int> ans;
for (int k=0; k<N; k++){
if (fr[k] > u) break;
if (fr[k] >= l && fr[k] <= u){
for (int i=0; i<=k; i++){
ans.push_back(L[i].second);
}
sort(ans.begin(), ans.end());
return ans;
}
if (bk[k] >= l && bk[k] <= u){
for (int i=N-1; i>= N-k-1; i--){
ans.push_back(L[i].second);
}
sort(ans.begin(), ans.end());
return ans;
}
if (fr[k] < l && bk[k] > u){
int f = 0;
int r = k-1;
int temp = fr[k];
while (true){
f += 1;
r += 1;
temp -= L[f-1].first;
temp += L[r].first;
if (temp <= u && temp >= l){
for (int i=f; i<=r; i++){
ans.push_back(L[i].second);
}
sort(ans.begin(), ans.end());
return ans;
}
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
464 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
572 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
808 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
884 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
916 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
916 KB |
OK (n = 100, answer = YES) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
916 KB |
sum of weights should be in [302..304] but it is 252 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
464 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
572 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
808 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
884 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
916 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
916 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
916 KB |
sum of weights should be in [302..304] but it is 252 |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
464 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
572 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
808 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
884 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
916 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
916 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
916 KB |
sum of weights should be in [302..304] but it is 252 |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
464 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
572 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
808 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
884 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
916 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
916 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
916 KB |
sum of weights should be in [302..304] but it is 252 |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
464 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
572 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
808 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
808 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
884 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
916 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
916 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
916 KB |
sum of weights should be in [302..304] but it is 252 |
21 |
Halted |
0 ms |
0 KB |
- |