# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
974377 | tamir1 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 348 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) {
vector<int> ans={};
int n=w.size(),sum=0,m,k,p,x=0;
for(int i=0;i<n;i++) sum+=w[i];
if(sum<l) return ans;
sort(w.begin(),w.end());
sum=0;
for(int i=0;i<n;i++){
if(sum+w[i]>u) break;
sum+=w[i];
m=i+1;
}
k=n-1;
p=0;
while(sum<l){
if(k<m || p==m) break;
x++;
sum+=w[k];
sum-=w[p];
k--;
p++;
}
if(sum<l) return {};
for(int i=x;i<m;i++) ans.push_back(w[i]);
for(int i=n-1;i>=n-x;i--) ans.push_back(w[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... |