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();vector<pair<int,int>> s;vector<int> r;
for(int i=0;i<n;i++)s.push_back({w[i],i});
sort(s.begin(),s.end());
vector<pair<int,int>> mi,ma;mi.push_back(s[0]);ma.push_back(s.back());
int as=mi[0].first,bs=ma[0].first;
for(int i=0;i<n;i++){
if(i>0){mi.push_back(s[i]);ma.push_back(s[n-1-i]);
//for(auto j:mi)cerr<<j.first<<' ';cerr<<endl;for(auto j:ma)cerr<<j.first<<' ';cerr<<endl;cerr<<endl;
as+=mi[i].first,bs+=ma[i].first;}
if(as<=l&&bs>=l){
//for(auto j:mi)cerr<<j.first<<' ';cerr<<endl;for(auto j:ma)cerr<<j.first<<' ';cerr<<endl;
for(int j=0;j<=i+1;j++){
if(as>=l&&as<=u)break;
if(j==i+1)exit(1);
as-=mi[j].first;mi[j]=ma[j];as+=mi[j].first;
}
for(auto i:mi)r.push_back(i.second);
return r;
}
if(as>=l&&as<=u){
for(auto i:mi)r.push_back(i.second);
return r;
}
if(as>u)break;
}
return r;
}
# | 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... |