#include <bits/stdc++.h>
#ifndef ARTHUR_LOCAL
#include "molecules.h"
#endif
using namespace std;
using ll = long long;
vector<int> find_subset(int u, int d, vector<int> W_raw)
{
int n = W_raw.size();
int l = ll(u);
int r = ll(d);
vector<pair<ll,int>> W;
for(int i=0; i<n; i++)
{
W.push_back(make_pair(ll(W_raw[i]),i));
}
sort(W.begin(),W.end());
ll cur1=0;
ll cur2=0;
vector<int> v1;
vector<int> v2;
bool works=0;
for(int i=1; i<=n; i++)
{
cur1 += W[i-1].first;
v1.push_back(i-1);
cur2 += W[n-i].first;
v2.push_back(n-i);
if(cur1 >= l && cur1 <= r)
{
// return cur1 things
return v1;
}
if(cur2 >= l && cur2 <= r)
{
return v2;
}
if(cur1 < l && cur2 > r) // LOOKS DODGY, PROBABLY IS RIGHT
{
works=1;
break;
}
}
if(!works) return {};
// definitely at this point
for(int i=0; i<v1.size(); i++)
{
cur2 -= ll(W_raw[v2[v1.size()-i-1]]);
cur2 += ll(W_raw[v1[i]]); // after this update, cur2 decreases by at most
v2[v1.size()-i-1]=v1[i];
if(cur2 <= r && cur2 >= l) return v2;
}
return {};
}
#ifdef ARTHUR_LOCAL
int main()
{
vector<int> V = find_subset(50,51,{25,26});
cout << V.size() << endl;
for(auto v:V) cout << v << " ";
}
#endif
Compilation message
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:59:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v1.size(); i++)
~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 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 |
256 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 |
380 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 |
376 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
5 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
6 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
7 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
8 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
9 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
10 |
Correct |
2 ms |
252 KB |
OK (n = 12, answer = YES) |
11 |
Correct |
2 ms |
256 KB |
OK (n = 100, answer = NO) |
12 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [50..51] but it is 35 |
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 |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 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 |
256 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 |
380 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 |
376 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
2 ms |
252 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
2 ms |
256 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [50..51] but it is 35 |
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 |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 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 |
256 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 |
380 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 |
376 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
2 ms |
252 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
2 ms |
256 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [50..51] but it is 35 |
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 |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 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 |
256 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 |
380 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 |
376 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
2 ms |
252 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
2 ms |
256 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [50..51] but it is 35 |
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 |
376 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
2 ms |
376 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
2 ms |
376 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 |
256 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 |
380 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 |
376 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
25 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
26 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
27 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
28 |
Correct |
2 ms |
376 KB |
OK (n = 6, answer = YES) |
29 |
Correct |
2 ms |
252 KB |
OK (n = 12, answer = YES) |
30 |
Correct |
2 ms |
256 KB |
OK (n = 100, answer = NO) |
31 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [50..51] but it is 35 |
32 |
Halted |
0 ms |
0 KB |
- |