# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1264540 | happyboy | Detecting Molecules (IOI16_molecules) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
long long n,l,u,w[200000];
pair<long long,int> p[200000];
bool o(pair<long long,int> a,pair<long long,int> b){
return a.f<b.f;
}
int main(){
cin>>n>>l>>u;
for (int i=0;i<n;i++){
cin>>w[i];
p[i]={w[i],i};
}
sort(p,p+n,o);
int l1=0,r1=0;
long long sum=p[0].f;
while (l1<=r1){
if (sum>=l&&sum<=u){
cout<<r1-l1+1<<"\n";
for (int i=l1;i<=r1;i++){
if (i!=l1) cout<<" ";
cout<<p[i].s;
}
cout<<"\n";
return 0;
}
else if (sum<l&&r1<n) sum+=p[++r1].f;
else sum-=p[l1++].f;
}
cout<<"0\n";
}