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>
#include<algorithm>
#include<vector>
#include<cmath>
int a,i,p[22],d[22],l,x[22];
double P[22],D[22];
double m,s;
double max(double XX,double YY){return XX>YY?XX:YY;}
void uu(int K,double S)
{
if(K==0)
{
s+=S;
}
else
{
for(int U=0;U<l;U++)
{
if(x[U]==0)
{
x[U]=1;
uu(K-1,S*(double)((double)1-P[U]/(double)100));
x[U]=0;
}
}
}
}
void f(int xx)
{
if(xx==a)
{
double per=0,sum=0;
for(int j=0;j<l;j++)
{
sum=0;
x[j]=1;
for(int k=0;k<l;k++)
{
s=0;
uu(k,(double)1);
for(int L=0;L<=k;L++)
{
s/=(double)(l-L);
}
sum+=s;
}
x[j]=0;
per+=sum*(P[j]/100)*D[j];
}
m=max(m,per);
}
else
{
f(xx+1);
P[l]=(double)p[xx];
D[l]=(double)d[xx];
l++;
f(xx+1);
l--;
P[l]=0;
D[l]=0;
}
}
main()
{
scanf("%d",&a);
for(i=0;i<a;i++)
{
scanf("%d%d",&p[i],&d[i]);
}
f(0);
printf("%.10lf",m);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |