# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
379871 | Pichon5 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 364 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>
#define lcm(a,b) (a/__gcd(a,b))*b
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define F first
#define S second
#define mp make_pair
using namespace std;
bool check(int x, int l, int r){
if(x>=l && x<=r){
return true;
}
return false;
}
vector<int> find_subset(int l, int r,vector<int> w) {
vector<pair<int,int> >v;
for(int i=0;i<w.size();i++){
v.pb({w[i],i});
}
sort(v.begin(),v.end());
int pref[w.size()];pref[0]=v[0].F;
for(int i=1;i<w.size();i++){
pref[i]=pref[i-1]+v[i].F;
}
vi res;
if(pref[0]>=l && pref[0]<=r){
res.pb(v[0].S);
return res;
}
for(int i=1;i<w.size();i++){
int L=0,R=i;
while(L<=R){
int mid=(L+R)/2;
int sum=pref[i];
if(mid>0)sum-=pref[mid-1];
if(check(sum,l,r)){
for(int l=0;l<=i;l++){
res.pb(v[l].S);
}
return res;
}
if(sum<l){
R=mid-1;
}else{
L=mid+1;
}
}
}
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... |