#pragma once
#include <bits/stdc++.h>
#define MAX_N 500000
using namespace std;
long long L[MAX_N], D[MAX_N];
int N;
set<long long> S;
vector<int> find_subset(int l, int u, vector<int> w) {
N=w.size();
sort(w.begin(), w.end());
L[0]=w[0];
for(int i=0; i<N; ++i){
if(i)
L[i]=L[i-1]+w[i];
if(L[i]>=l && L[i]<=u){
vector<int> ret;
int sum=0;
for(int j=0; j<i+1; ++j){
ret.push_back(j);
sum+=w[j];
}
assert(l<=sum && sum<=u);
return ret;
}
}
D[N-1]=w[N-1];
for(int i=N-1; i>=0; --i){
if(N-1-i)
D[i]=D[i+1]+w[i];
if(D[i]>=l && D[i]<=u){
vector<int> ret;
int sum=0;
for(int j=N-1; j>=i; --j){
ret.push_back(j);
sum+=w[j];
}
assert(l<=sum && sum<=u);
return ret;
}
}
for(int i=N-2; i>=0; --i){
S.insert(D[i+1]);
auto x=S.lower_bound((long long)l-L[i]);
if(x==S.end())continue;
long long val=*x;
if(val<=(long long)u-L[i]){
//To je to, nasao sam resenje
vector<int> ret;
int ind=-1;
for(int j=i+1; j<N; ++j)
if(D[j]==val)
ind=j;
int sum=0;
for(int j=0; j<=i; ++j){
ret.push_back(j);
sum+=w[j];
}
assert(sum==L[i]);
for(int j=ind; j<N; ++j){
ret.push_back(j);
sum+=w[j];
}
assert(sum==L[i]+D[ind]);
assert(sum<=u && sum>=l);
return ret;
}
}
vector<int> ret;
return ret;
}
Compilation message
molecules.cpp:1:9: warning: #pragma once in main file
#pragma once
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
360 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
408 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
584 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
7 ms |
584 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
584 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
3 ms |
584 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
592 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
5 ms |
592 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = YES) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
4 ms |
756 KB |
OK (n = 12, answer = NO) |
5 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
6 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
7 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
8 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
9 |
Correct |
2 ms |
756 KB |
OK (n = 6, answer = YES) |
10 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
11 |
Correct |
3 ms |
756 KB |
OK (n = 100, answer = NO) |
12 |
Incorrect |
2 ms |
756 KB |
sum of weights should be in [50..51] but it is 73 |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
360 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
408 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
584 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
7 ms |
584 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
584 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
3 ms |
584 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
592 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
5 ms |
592 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
4 ms |
756 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
756 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
3 ms |
756 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
756 KB |
sum of weights should be in [50..51] but it is 73 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
360 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
408 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
584 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
7 ms |
584 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
584 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
3 ms |
584 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
592 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
5 ms |
592 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
4 ms |
756 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
756 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
3 ms |
756 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
756 KB |
sum of weights should be in [50..51] but it is 73 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
360 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
408 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
584 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
7 ms |
584 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
584 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
3 ms |
584 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
592 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
5 ms |
592 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
4 ms |
756 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
756 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
3 ms |
756 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
756 KB |
sum of weights should be in [50..51] but it is 73 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
360 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
408 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
2 ms |
584 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
7 ms |
584 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
584 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
3 ms |
584 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
2 ms |
592 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
5 ms |
592 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
3 ms |
592 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
3 ms |
712 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
2 ms |
712 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
2 ms |
756 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
4 ms |
756 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
756 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
756 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
3 ms |
756 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
3 ms |
756 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
756 KB |
sum of weights should be in [50..51] but it is 73 |
32 |
Halted |
0 ms |
0 KB |
- |