| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 134654 | Muhammetali | Detecting Molecules (IOI16_molecules) | C++11 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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] << " ";
}
}
