# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881843 | theghostking | Detecting Molecules (IOI16_molecules) | C++17 | 1057 ms | 436 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 "molecules.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
long long n = w.size();
vector<pair<long long,long long>> vec(n);
for (long long i = 0; i<n; i++){
vec[i] = {w[i],i};
}
sort(vec.begin(),vec.end());
vector<bool> vis(n);
long long pt = n-1;
long long cr = 0;
while (pt >= 0){
if (cr < l){
cr += vec[pt].first;
vis[pt] = true;
pt--;
}
if (pt < 0) break;
if ((l <= cr) && (cr <= u)){
break;
}
int lm = pt;
//can go from 0...pt, and pt+1,...,n-1
int o = 0;
int r = n-1;
while (cr > u){
if (o > pt) break;
if (r < pt) break;
if (!(o<r)) break;
cr -= vec[r].first;
cr += vec[o].first;
vis[r] = false;
vis[o] = true;
r--;
o++;
}
if ((l <= cr) && (cr <= u)) break;
}
vector<int> ans;
if (cr < l || cr > u){
return ans;
}
else{
for (long long i = 0; i<n; i++){
if (vis[i]) ans.push_back(i);
}
return ans;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |