# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
432649 | Belgutei | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 320 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;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
vector<int> v;
vector<pair<int,int> > w;
std::vector<int> find_subset(int l, int u, std::vector<int> ww) {
for(int i=0; i<ww.size(); i++){
w.pb(mk(ww[i],i));
}
sort(w.begin(),w.end());
bool ok=0;
for(int k=1; k<=w.size() && ok==0; k++){
ll sum=0;
for(int j=0; j<k; j++){
sum+=w[j].ff;
}
if(sum>u) break;
if(l<=sum){
for(int j=0; j<k; j++){
v.pb(w[j].ss);
}
break;
}
int x=0;
int y=w.size()-1;
while(x<y && x<=k-1){
sum-=w[x].ff;
sum+=w[y].ff;
if(sum>=l){
for(int i=(x+1); i<=k-1; i++){
v.pb(w[i].ss);
}
for(int i=w.size()-x-1; i<w.size(); i++){
v.pb(w[i].ss);
}
ok=1;
break;
}
x++;
y--;
}
}
return v;
}
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... |