# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96270 | figter001 | Detecting Molecules (IOI16_molecules) | C++14 | 2 ms | 504 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>
#include "molecules.h"
using namespace std;
typedef long long ll;
const int N = 2e5+50;
ll sum[N];
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ans;
sort(w.begin(),w.end());
sum[0] = w[0];
for(int i=1;i<w.size();i++)sum[i] = sum[i-1] + w[i];
for(int i=0;i<w.size();i++){
int md,lo=i,hi=w.size()-1,to=-1;
while(lo <= hi){
md = (lo+hi)/2;
ll cur = sum[md];
if(i)cur -= sum[i-1];
if(cur >= l && cur <= u){
to = md;
break;
}
if(cur > u)hi = md-1;
else if(cur < l)lo = md+1;
}
if(to != -1){
for(int j=i;j<=to;j++)ans.push_back(j);
break;
}
}
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... |