Codeforces 42A guilty-to the kitchen!

Source: Internet
Author: User

Guilty-to the kitchen!Time limit:2000MS Memory Limit:262144KB 64bit IO Format:%i64d &%i6 4u SubmitStatusPracticecodeforces 42A

Description

It ' s a very unfortunate day for Volodya today. He got bad mark in algebra and is therefore forced to doing some work on the kitchen, namely to cook borscht (traditional Ru Ssian soup). This should also improve his algebra skills.

According to the borscht recipe it consists ofNIngredients that has to is mixed in proportion litres (thus, there should is a1 · X, ..., an · x litres of corresponding ingredients mixed for some non-negative x). In the kitchen Volodya found off that he has b1, ..., bn litres of these I Ngredients at his disposal correspondingly. In order to correct his algebra mistakes he ought to cook as much soup as possible in a V litres volume pa N (which means the amount of soup cooked can be between 0 and V litres). What is the volume of borscht Volodya would cook ultimately?

Input

The first line of the input contains the space-separated integers n and V (1≤ n ≤ 20, 1≤ V ≤10000). The next line contains n space-separated integers ai (1≤ a c15>i ≤100). Finally, the last line contains n space-separated integers bi (0≤< C24>bi ≤100).

Output

Your program should output just one real number-the volume of soup, that Volodya would cook. Your answer must has a relative or absolute error less than -4.

Sample Input

Input
1 100
1
40
Output
40.0
Input
2 100
1 1
25 30
Output
50.0
Input
2 100
1 1
60 60
Output
100.0
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 structNode6 {7     DoubleA;8     Doubleb;9     DoubleC;Ten}s[ -]; One  A BOOLcmp (Node x,node y) - { -     returnx.c<y.c; the } - intMain () - { -     intn,i,j; +     Doublea[ -],b[ -],c[ -],v; -      while(SCANF ("%d%lf", &n,&v)! =EOF) +     { A          for(i=1; i<=n;i++) atscanf"%LF",&s[i].a); -          for(i=1; i<=n;i++) -         { -scanf"%LF",&s[i].b); -s[i].c=s[i].b/s[i].a; -         } inSort (s+1, s+n+1, CMP); -         Doubleans=0; to          for(i=1; i<=n;i++) +ans=ans+s[1].c*s[i].a; -         if(ans>v) theans=v; *printf"%lf\n", ans); $     }Panax Notoginseng     return 0; -}
View Code

Codeforces 42A guilty-to the kitchen!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.