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<bits/stdc++.h>
using namespace std;
#include "molecules.h"
long long st,md,ed;
vector<int> emptyvec;
vector<pair<long long,long long> > v;
long long query(long long l,long long r)
{
if(l==0)
{
return v[r].first;
}
return v[r].first-v[l-1].first;
}
std::vector<int> find_subset(int l,int u, std::vector<int> w) {
for(int i=0;i<w.size();i++)
{
v.push_back(make_pair(w[i],i));
}
sort(v.begin(),v.end());
for(int i=1;i<v.size();i++)
{
v[i].first+=v[i-1].first;
}
/*for(int i=0;i<v.size();i++)
{
for(int j=i;j<v.size();j++)
{
printf("%d %d %lld\n",i,j,query(i,j));
}
}*/
for(int i=0;i<v.size();i++)
{
st=i;
ed=v.size()-1;
//printf("%d\n",i);
while(ed>=st)
{
md=(st+ed)/2;
//printf("%lld %lld %lld\n",st,md,ed);
if(query(i,md)>=l)
{
ed=md-1;
}else
{
st=md+1;
}
}
//printf("%lld %lld %lld\n",st,md,ed);
if(st<v.size())
{
if(query(i,st)<=u)
{
for(int j=i;j<=st;j++)
{
emptyvec.push_back(v[j].second);
}
return emptyvec;
}
}
}
return emptyvec;
}
Compilation message (stderr)
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i=0;i<w.size();i++)
| ~^~~~~~~~~
molecules.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i=1;i<v.size();i++)
| ~^~~~~~~~~
molecules.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
molecules.cpp:50:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | if(st<v.size())
| ~~^~~~~~~~~
# | 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... |