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 ...
随机推荐
- 【crunch bang】 tint2-用来控制桌面的布局
tint2配置: #--------------------------------------------- # TINT2 CONFIG FILE #----------------------- ...
- Azure Deploy
http://msdn.microsoft.com/en-us/library/dn408531.aspx https://www.windowsazure.com/en-us/documentati ...
- SQLServer中在视图上使用索引(转载)
在SQL Server中,视图是一个保存的T-SQL查询.视图定义由SQL Server保存,以便它能够用作一个虚拟表来简化查询,并给基表增加另一层安全.但是,它并不占用数据库的任何空间.实际上,在你 ...
- Mongodb 笔记08 了解应用的动态、数据管理、持久性
了解应用的动态 1. 了解正在进行的操作:db.currentOp() , 可以加过滤条件,从而只显示符合条件的结果. 1). 寻找有问题的操作:db.currentOp() 最常见的操作就是用来寻找 ...
- React笔记_(1)_react概述
React概述 React是一种很好的前端技术. 它将应用打散成独立的小模块,然后进行组装,完成开发. react远比angularjs难学的多. react依赖的如webpack等各种工具得先学 ...
- linux mmap 内存映射【转】
转自:http://blog.csdn.net/xyyangkun/article/details/7830313 [-] mmap vs readwritelseek mmap vs malloc ...
- python 读取全国城市aqi数据,差值生成png图片
# -*- coding: utf-8 -*- import arcpy import sys import datetime import cx_Oracle import json import ...
- 调整iFrame高度
在Chrome中,即使将iframe的高度设置为100%,也无法根据内容页自动调节高度,需要在iframe的onload even中通过计算设置iframe的高度 function setIframe ...
- SQLServer学习笔记<>sql的范围内查找,sql数据类型,字符串处理函数
sql的范围内查找 (1)between.....and用法 通常情况下我们查找一个在某固定区域内的所有记录,可以采用>=,<=来写sql语句,例如:查找订单价格在1000到2000之间的 ...
- C#:通过Window API接口实现WiFi
1.获取Mac地址 //WiFi通知回调 private WlanApi.WLAN_NOTIFICATION_CALLBACK _notificationCallback; this._notific ...