# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831328 | Supersonic | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 212 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;
typedef long long ll;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
ll n=w.size();
ll ls[n];ll rs[n];
vector<pair<ll,ll>> s;
for(ll 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;
ll 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(ll 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<ll,ll>> rr;
ll lp=0;
for(ll i=0;i<=b;i++){rr.push_back(s[i]);lp+=s[i].first;}
ll ci=0;
ll ib=b;
while(lp<l){
if(ci==rr.size())exit(1);
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... |