#include <cstdio>
#include <vector>
#include <cassert>
#include <bits/stdc++.h>
#include "molecules.h"
#define maxn 200005
#define pb push_back
using namespace std;
typedef long long ll;
int n;
ll pref[maxn];
ll suff[maxn];
int a,b;
bool dobar(ll x){
if(x >=a && x<=b)return 1;
return 0;
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
sort(w.begin(), w.end());
n = w.size();
ll tren = 0;
a = l;
b = u;
for(int i=0; i<n; i++){
tren += w[i];
pref[i + 1] = tren;
}
if(dobar(pref[n])){
vector<int> rez;
for(int i=0; i<n; i++)rez.push_back(i);
return rez;
}
tren = 0;
for(int i=n; i>=1; i--){
tren += w[i - 1];
suff[n - i + 1] = tren;
}
bool ima = 0;
int le=0,de=0;
for(int i=0; i<=n; i++){
//cout << i << endl;
de = i;
ll sum = suff[i];
// cout << i << " " << suff[i] << endl;
if(sum > u)break;
//cout << sum << endl;
ll pom = l - sum;
ll prvi;
if(pom <= 0){
//cout << i << endl;
ima = 1;
break;
}
else{
prvi = lower_bound(pref, pref + n + 1, pom) - pref;
}
if(prvi > n)prvi = n;
if(pref[prvi] + sum > pref[n])continue;
if(dobar(pref[prvi] + sum)){
ima = 1;
le = prvi;
break;
}
}
// cout << de << endl;
vector<int>rez;
if(!ima)return rez;
int koji = n - de;
for(int i=1; i<=le; i++)rez.pb(i - 1);
for(int i=n-1; i>=koji; i--)rez.pb(i);
return rez;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
252 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
376 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 |
256 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 |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
252 KB |
OK (n = 100, answer = YES) |
# |
결과 |
실행 시간 |
메모리 |
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 |
360 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
5 |
Correct |
3 ms |
376 KB |
OK (n = 12, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
7 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
8 |
Correct |
2 ms |
376 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 |
348 KB |
OK (n = 100, answer = NO) |
12 |
Incorrect |
3 ms |
376 KB |
sum of weights should be in [50..51] but it is 73 |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
252 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
376 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 |
256 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 |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
252 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 |
360 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
3 ms |
376 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
376 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 |
348 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
3 ms |
376 KB |
sum of weights should be in [50..51] but it is 73 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
252 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
376 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 |
256 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 |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
252 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 |
360 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
3 ms |
376 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
376 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 |
348 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
3 ms |
376 KB |
sum of weights should be in [50..51] but it is 73 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
252 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
376 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 |
256 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 |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
252 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 |
360 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
3 ms |
376 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
376 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 |
348 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
3 ms |
376 KB |
sum of weights should be in [50..51] but it is 73 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
2 ms |
256 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
252 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
256 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
376 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 |
256 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 |
2 ms |
376 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
376 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
252 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 |
360 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
3 ms |
376 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
376 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 |
348 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
3 ms |
376 KB |
sum of weights should be in [50..51] but it is 73 |
32 |
Halted |
0 ms |
0 KB |
- |