# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
444645 | Hanksburger | 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;
pair<long long, long long> a[200000];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, l, r, index=0, sum=0;
cin >> n >> l >> r;
for (long long i=0; i<n; i++)
{
cin >> a[i].first;
a[i].second=i;
}
sort(a, a+n);
for (long long i=0; i<n; i++)
{
while (1)
{
if (l<=sum && sum<=r)
{
cout << index-i << '\n';
for (long long j=i; j<index; j++)
cout << a[j].second << ' ';
return 0;
}
if (index<n && sum<=r)
{
sum+=a[index].first;
index++;
}
else
break;
}
sum-=a[i].first;
}
cout << 0;
return 0;
}