# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831326 | Supersonic | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 300 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;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n=w.size();
int ls[n];int rs[n];
vector<pair<int,int>> s;
for(int i=0;i<n;i++)s.push_back({w[i],i});
sort(s.begin(),s.end());
ls[0]=s[0].first;rs[0]=s[n-1].first;
int b=-1;
if(ls[0]<=l&&u<=rs[0])b=0;
if(ls[0]>=l&&ls[0]<=u)b=0;
if(rs[0]>=l&&rs[0]<=u)b=0;
for(int i=1;i<n;i++){
ls[i]=ls[i-1]+s[i].first;rs[i]=rs[i-1]+s[n-1-i].first;
if(ls[i]<=l&&u<=rs[i])b=i;
if(ls[i]>=l&&ls[i]<=u)b=i;
if(rs[i]>=l&&rs[i]<=u)b=i;
//cerr<<ls[i]<<' '<<rs[i]<<endl;
}
//cerr<<b<<endl;
if(b==-1)return {};
vector<pair<int,int>> rr;
int lp=0;
for(int i=0;i<=b;i++){rr.push_back(s[i]);lp+=s[i].first;}
int ci=0;
int ib=b;
while(lp<l){
while(b<s.size()){
lp-=rr[ci].first;
rr[ci]=s[b];lp+=s[b].first;b++;
if(lp>=l)break;
}
if(lp>=l)break;
ci++;ib++;b=ib;s.pop_back();
}
vector<int> r;
for(auto i:rr)r.push_back(i.second);
return r;
}
//6 7 8 8
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... |