CodeForces 42A Guilty — to the kitchen!
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
It's a very unfortunate day for Volodya today. He got bad mark in algebra and was therefore forced to do some work in the kitchen, namely to cook borscht (traditional Russian soup). This should also improve his algebra skills.
According to the borscht recipe it consists of n ingredients that have to be mixed in proportion litres (thus, there should be a1 ·x, ..., an ·x litres of corresponding ingredients mixed for some non-negative x). In the kitchen Volodya found out that he has b1, ..., bn litres of these ingredients 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 pan (which means the amount of soup cooked can be between 0 and V litres). What is the volume of borscht Volodya will cook ultimately?
Input
The first line of the input contains two space-separated integers n and V (1 ≤ n ≤ 20, 1 ≤ V ≤ 10000). The next line contains n space-separated integers ai (1 ≤ ai ≤ 100). Finally, the last line contains n space-separated integers bi (0 ≤ bi ≤ 100).
Output
Your program should output just one real number — the volume of soup that Volodya will cook. Your answer must have a relative or absolute error less than 10 - 4.
Sample Input
- 1 100
1
40
- 40.0
- 2 100
1 1
25 30
- 50.0
- 2 100
1 1
60 60
- 100.0
- #include <stdio.h>
- #include <string.h>
- #include <algorithm>
- using namespace std;
- struct Node
- {
- double a;
- double b;
- double c;
- }s[];
- bool cmp(Node x,Node y)
- {
- return x.c<y.c;
- }
- int main()
- {
- int n,i,j;
- double a[],b[],c[],v;
- while(scanf("%d %lf",&n,&v)!=EOF)
- {
- for(i=;i<=n;i++)
- scanf("%lf",&s[i].a);
- for(i=;i<=n;i++)
- {
- scanf("%lf",&s[i].b);
- s[i].c=s[i].b/s[i].a;
- }
- sort(s+,s+n+,cmp);
- double ans=;
- for(i=;i<=n;i++)
- ans=ans+s[].c*s[i].a;
- if(ans>v)
- ans=v;
- printf("%lf\n",ans);
- }
- return ;
- }
CodeForces 42A Guilty — to the kitchen!的更多相关文章
- Codeforces Gym 100610 Problem K. Kitchen Robot 状压DP
Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10061 ...
- Codeforces Gym-102219 2019 ICPC Malaysia National J. Kitchen Plates (暴力,拓扑排序)
题意:给你5个\(A,B,C,D,E\)大小关系式,升序输出它们,如果所给的大小矛盾,输出\(impossible\). 题意:当时第一眼想到的就是连边然后排序,很明显是拓扑排序(然而我不会qwq,之 ...
- Codeforces gym 100685 C. Cinderella 水题
C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...
- Codeforces 1032 - A/B/C/D/E - (Undone)
链接:http://codeforces.com/contest/1032/ 是真的真的真的忍不住想吐槽这题意是真的真的真的读不懂…… A - Kitchen Utensils - [简单数学题] 题 ...
- CF&&CC百套计划1 Codeforces Round #449 B. Ithea Plays With Chtholly
http://codeforces.com/contest/896/problem/B 题意: 交互题 n张卡片填m个1到c之间的数,1<=n*ceil(c/2)<=m 最后填出一个单调非 ...
- Codeforces Round #449 (Div. 2)ABCD
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Lesson 11 Not guilty
Lesson 11 Not guilty guilty ['gɪlti] adj. 有罪的:内疚的 be guilty of - He is guilty of murder. be innocent ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
随机推荐
- 夺命雷公狗---DEDECMS----33dedecms自定义搜索以及分页功能完成
我们现在要开始实现模版里面的搜索功能了,我们先找要做出一个检索提交表单,如下所示: 只要我们点击生成之后我们的表单就获取到了,可以直接拿生成好的html表单拿来用来测试下.. 将他嵌入首页的模版文件, ...
- 【RoR win32】新建rails项目找不到script/server的解决办法
现象: D:\>rails new work/demo cd work/demo D:\work\demo>ruby script/server 这时显示出错: ruby: No such ...
- ApkDec android反编译工具
转自:http://www.newasp.net/soft/70498.html 下载 ApkDec是一款免费的绿色APK反编译工具 forandroid ,由android开发者社区开发. ApkD ...
- TVideoGrabber如何并行处理多摄像头
大家都知道 TVideoGrabber是一款支持包括C#..NET.VB.NET.C++.Delphi.C++Builder和ActiveX平台在内的视频处理控件,可以捕捉视频,也可以作为多媒体播放器 ...
- android 学习随笔八(异常处理总结)
1.在android 中开发java.net.SocketException: socket failed: EACCES (Permission denied) 报错 第一反应就是缺少网络权限,然后 ...
- sql如何将同个字段不同值打印在一行
group_concat(distinct(img)) group by id通过id分组把img的值打印在一行group_concat()通常和group by一起使用,功能是把某个字段的值打印在一 ...
- kdump failed
kdump 是一种先进的基于 kexec 的内核崩溃转储机制.当系统崩溃时,kdump 使用 kexec 启动到第二个内核. 第二个内核通常叫做捕获内核,以很小内存启动以捕获转储镜像.第一个内核保留 ...
- TI CC2541的中断优先级设置.
实际看到的中断优先级设置是这样的:
- 非常好!!!【从头开始写操作系统系列】实现一个-GDT(1)【转】
转自:http://blog.csdn.net/luoyhang003/article/details/47338019 权声明:本文为博主原创文章,未经博主允许不得转载.(文章来源:http://b ...
- Linux环境变量的修改(永久,暂时)以及修改ls显示的时间格式
本文转自:http://blog.sina.com.cn/s/blog_8e21864f01014u9h.html Linux修改环境变量,很简单但很重要 一.Linux的变量种类 按变量的生存周期来 ...