#include <bits/stdc++.h>
#define pii pair<int,int>
#define iii pair<int,pii>
#define fi first
#define se second
#define vi vector<int>
#define vii vector<pii>
#define pb(i) push_back(i)
#define all(x) x.begin(),x.end()
#define TEXT "a"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int inf = 1e9 + 7;
const ld eps = 1e-8;
const double pi = acos(-1);
vector<int> find_subset(int l,int r,vector<int> w){
int n = w.size();
vector<pii> a(n);
for (int i = 0; i < n; i++){
a[i] = pii(w[i],i);
}
sort(all(a));
ll sum = 0;
for (int i = 0; i < n; i++){
sum += a[i].fi - a[0].fi;
}
vector<int> res;
for (ll x = 1; x <= n; x++){
ll c = l - x * a[0].fi;
ll d = r - x * a[0].fi;
if (d < 0) break;
if (sum < c) continue;
ll cur = 0;
for (int j = n - 1; j >= 0; j--){
int p = a[j].fi - a[0].fi;
if (cur + p > d) continue;
cur += p;
res.push_back(a[j].se);
if (res.size() == x) break;
}
if (res.size() != x) return {};
break;
}
return res;
}
//
//int main(){
// int l = 15,r = 17;
// vector<int> w = {6,8,8,7};
// vi v = find_subset(l,r,w);
// for (int i : v) cout << i << " "; cout << "\n";
// l = 14, r = 15;
// w = {5,5,6,6};
// v = find_subset(l,r,w);
// for (int i : v) cout << i << " "; cout << "\n";
// l = 10, r = 20;
// w = {15,17,16,18};
// v = find_subset(l,r,w);
// for (int i : v) cout << i << " "; cout << "\n";
// return 0;
//}
Compilation message
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:48:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
48 | if (res.size() == x) break;
| ~~~~~~~~~~~^~~~
molecules.cpp:50:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
50 | if (res.size() != x) return {};
| ~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
344 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
344 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 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 |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
604 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
344 KB |
OK (n = 100, answer = YES) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
5 |
Correct |
1 ms |
348 KB |
OK (n = 12, answer = YES) |
6 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
7 |
Correct |
0 ms |
392 KB |
OK (n = 12, answer = YES) |
8 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
9 |
Correct |
0 ms |
348 KB |
OK (n = 6, answer = YES) |
10 |
Correct |
0 ms |
432 KB |
OK (n = 12, answer = YES) |
11 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
12 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [50..51] but it is 12 |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
344 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
344 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 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 |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
604 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
344 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
1 ms |
348 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
0 ms |
392 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
0 ms |
348 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
0 ms |
432 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [50..51] but it is 12 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
344 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
344 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 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 |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
604 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
344 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
1 ms |
348 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
0 ms |
392 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
0 ms |
348 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
0 ms |
432 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [50..51] but it is 12 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
344 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
344 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 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 |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
604 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
344 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
1 ms |
348 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
0 ms |
392 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
0 ms |
348 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
0 ms |
432 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [50..51] but it is 12 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
344 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
1 ms |
344 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
1 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 |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
344 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
1 ms |
348 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
348 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
1 ms |
604 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
344 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
1 ms |
348 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
0 ms |
392 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
0 ms |
348 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
0 ms |
432 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
0 ms |
348 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
0 ms |
348 KB |
sum of weights should be in [50..51] but it is 12 |
32 |
Halted |
0 ms |
0 KB |
- |