# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
448388 | bonopo | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 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 <bits/stdc++.h>
using namespace std;
#define pb push_back
#define rc (i<<1)|1
#define lc (i<<1)
#define el "\n"
#define f first
#define s second
typedef long long ll;
const int MM=2e5+5, MOD=1e9+7;
int N, L, R; pair<int,int> a[MM];
int32_t main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin>>N>>L>>R;
for(int i=1, x; i<=N; ++i) cin>>x, a[i]={x, i-1};
sort(a, a+N+1);
ll sum=0;
for(int l=1, r=1; r<=N; ++r) {
sum+=a[r].f;
while(l<r&&sum>R) sum-=a[l++].f;
if(sum>=L&&sum<=R) {
cout<<r-l+1<<el;
for(int i=l; i<=r; ++i) cout<<a[i].s<<" \n"[i==r];
return 0;
}
}
cout<<0<<el;
}
// MM