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],l[21];
double p[21],d[21],mx;
double get (int t, double k, bool on)
{
int i,m;
double r=0;
if (t==w || on)
return k*on;
for (i=1;i<=w;i++)
if (l[i])
{
m=l[i];
l[i]=0;
r += get (t+1, k*p[m]*d[m]/(100*(w-t)), 1);
r += get (t+1, k*(100-p[m])/(100*(w-t)), 0);
l[i]=m;
}
return r;
}
void go (int t, int is)
{
c[t]=is;
if (t==n)
{
w=0;
for (int i=1;i<=n;i++)
if (c[i])
l[++w]=i;
double k=get (0,1,0);
if (mx<k)
mx=k;
}
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",mx);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |