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;
int sommepetit,sommegrand,trouve,nb,sommeec,ec;
vector<int> rep;
vector<pair<int,int>> poids;
vector<int> find_subset(int debrep, int finrep,vector<int> p) {
for (int i=0;i<(int)p.size();i++){
poids.push_back(make_pair(p[i],i));
}
sort(poids.begin(),poids.end());
for (int i=0;i<(int)poids.size();i++){
if (trouve==0){
sommepetit+=poids[i].first;
sommegrand+=poids[poids.size()-i-1].first;
if (sommepetit<=debrep and sommegrand>=finrep){
nb=i;
trouve=1;
}
if (sommepetit>=debrep and sommepetit<=finrep){
for (int j=0;j<=i;j++){
rep.push_back(poids[j].second);
}
return rep;
}
if (sommegrand>=debrep and sommegrand<=finrep){
for (int j=0;j<=i;j++){
rep.push_back(poids[poids.size()-j-1].second);
}
return rep;
}
}
}
if (trouve==0){
return rep;
}
trouve=0;
sommeec=sommepetit;
while (sommeec<debrep){
sommeec-=poids[ec].first;
ec++;
sommeec+=poids[ec+nb].first;
}
for (int i=0;i<ec;i++){
rep.push_back(poids[i+ec].second);
}
return rep;
}
# | 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... |