# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
553221 | sandry24 | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
int find_subset(int l, int u, int w[], int n, int result[]){
sort(w, w+n, greater<int>());
ll sum = 0;
int ind = 0;
vector<int> visited(n);
while(ind != n){
if(sum + w[ind] < l){
sum += w[l];
visited[ind] = 1;
}
ind++;
}
for(int i = n-1; i >= 0; i--){
if(!visited[i]){
sum += w[i];
visited[ind] = 1;
break;
}
}
if(sum >= l && sum <= u){
int m = 0;
for(int i = 0; i < n; i++){
if(visited[i]){
cout << i << ' ';
result[i] = w[i];
m++;
}
}
return m;
}
return 0;
}