raj_aman's blog

By raj_aman, history, 5 years ago, In English

problem big money can anyone help me to find out the error in my solution,i have worked on all extreme points of range:

double l1,r1,p1,l2,r2,p2;

int main() { ll m;cin>>m; ll n;cin>>n; while(n--) { cin>>l1>>r1>>p1>>l2>>r2>>p2; double ans=0.0+m;

if(m>=l1&&m<=r1)
        {
            double ans2=m+p1*m/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }
        if(m>=l2&&m<=r2)
        {
            double ans2=m+p2*m/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }
        ll a=l1,b=m-l1;
        if(a>=0&&b>=0)
        {  double ans2;
            if(b>=l2&&b<=r2)
            {  ans2=a+b+p1*a/100+p2*b/100;


            }
            else ans2=a+b+p1*a/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }
         a=r1,b=m-r1;
        if(a>=0&&b>=0)
        {  double ans2;
            if(b>=l2&&b<=r2)
            {  ans2=a+b+p1*a/100+p2*b/100;


            }
            else ans2=a+b+p1*a/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }

         a=r2,b=m-r2;
        if(a>=0&&b>=0)
        {  double ans2;
            if(b>=l1&&b<=r1)
            {  ans2=a+b+p1*b/100+p2*a/100;


            }
            else ans2=a+b+p2*a/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }

         a=l2,b=m-l2;
        if(a>=0&&b>=0)
        {  double ans2;
            if(b>=l1&&b<=r1)
            {  ans2=a+b+p2*a/100+p1*b/100;


            }
            else ans2=a+b+p2*a/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }


       //cout<<setprecision(100000000)<<fixed;
       cout<<setprecision(12)<<fixed;
       cout<<ans<<endl;



   }


return 0;

}

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it