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 <cstdio>
int n,w,c[21];
double as,p[21],d[21];
double get (int t, double k)
{
int i,m;
double r=0;
if (t<w)
for (i=1;i<=n;i++)
if (c[i])
{
c[i]=0;
r += k*p[i]*d[i]/100.0/(w-t);
r += get (t+1, k*(100.0-p[i])/100.0/(w-t));
c[i]=1;
}
return r;
}
void go (int t, bool y)
{
c[t]=y;
if (t==n)
{
w=0;
for (int i=1;i<=n;w+=c[i++]);
double k=get (0,1);
//printf ("%lf\n",k);
as=(as<k)?k:as;
}
else
{
go (t+1,0);
go (t+1,1);
}
}
int main ()
{
int i;
scanf ("%d",&n);
for (i=1;i<=n;i++)
scanf ("%lf%lf",p+i,d+i);
go (0,0);
printf ("%lf\n",as);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |