| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 134654 | Muhammetali | Detecting Molecules (IOI16_molecules) | C++11 | 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>
typedef long long ll;
using namespace std;
ll n,l,u,w[1001],m,e[1001],jem,h[1001],g,k,res;
int Lay(ll h[],ll e[],ll w[],ll g,ll k)
{
for (int i=0;i<n;i++)
{
if (w[i]==h[k])
{
w[i]=0;
e[g]=i;
return 0;
}
}
}
int main()
{
system("color 7E");
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> l >> u;
for (ll i=0;i<n;i++)
{
cin >> w[i];
res+=w[i];
h[i]=w[i];
}
sort(h,h+n);
if (u-l>=h[n-1]-h[0])
{
if (res<l)
{
cout << 0;
return 0;
}
if (res<l)
{
cout << 0;
return 0;
}
if (h[0]>=l && h[0]<=u && h[0]+h[1]>u)
{
cout << 1 << endl;
cout << 0;
return 0;
}
for (ll i=n-1;i>=0;i--)
{
jem+=h[i];
k=i;
if (jem<=u)
{
g++;
Lay(h,e,w,g,k);
}
if (jem>u)
{
jem-=h[i];
}
}
}
else
{
cout << 0;
return 0;
}
if (jem<l)
{
cout << 0;
return 0;
}
cout << g << endl;
sort (e+1,e+g+1);
for (ll i=1;i<=g;i++)
{
cout << e[i] << " ";
}
}
