# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642550 | rc_catunta | Detecting Molecules (IOI16_molecules) | C++17 | 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;
typedef pair<ll,int> ii;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<ii> v;
for(int i=0;i<w.size();i++){
v.push_back(ii(ll(w[i]),i));
}
sort(v.begin(),v.end());
// Acumuladas
vector<ll>a;
a.push_back(v[0].first);
for(int i=1;i<v.size();i++){
a.push_back(a[i-1]+v[i].first);
}
vector<int> res;
long long objetivo;
int pos;
for(int i=0;i<a.size();i++){
if(a[i]>=l and a[i]<=u){
// Es el rango de 0 hasta i
for(int k=0;k<=i;k++)
res.push_back(v[k].second);
return res;
}
int resl=-1,resu=-1;
if(a[i]>=l){
// Objetivo l
objetivo = a[i] - l;
pos = lower_bound(v.begin(),v.end(),ii(objetivo,0))-v.begin();
if(a[i]-a[pos]>=l and a[i]-a[pos]<=u){
resl=pos+1;
resu=i;
}
if(pos>0){
if(a[i]-a[pos-1]>=l and a[i]-a[pos-1]<=u){
resl=pos;
resu=i;
}
}
if(resu>=0 and resl>=0){
for(int k=resl;k<=resu;k++)
res.push_back(v[k].second);
return res;
}
}
}
res.clear();
return res;
}
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... |