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>
#define N 1000005
#define ll long long int
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
#include "molecules.h"
using namespace std;
ll n,m,ar[N],sum,t,pref[N];
lli p[N];
vector<int> v;
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
n=w.size();
fo(i,0,n-1)
p[i]={w[i],i};
sort(p,p+n);
fo(i,0,n-1)
pref[i]=pref[i-1]+p[i].fi;
int a=0,b=0;
while(b<n)
{
if(b<a)
b=a;
ll x=pref[b];
if(a!=0)
x-=pref[a-1];
if(x<l)
b++;
if(x>u)
a++;
if(x>=l && x<=u)
{
fo(i,a,b)
v.pb(p[i].se);
break;
}
}
return v;
}
vector<int> bos,ans;
// int main()
// {
// fast;
// int l,r;
// cin>>n>>l>>r;
// // int a;
// fo(i,1,n)
// {
// int a;
// cin>>a;
// bos.pb(a);
// }
// ans=find_subset(l,r,bos);
// for(int i=0;i<ans.size();i++)
// cout<<ans[i]<<sp;
// }
Compilation message (stderr)
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:43:6: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(a!=0)
^~
molecules.cpp:45:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(x<l)
^~
# | 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... |