PAT1070. Mooncake (25)
#include
#include
#include <stdio.h>
#include <math.h>
using namespace std;
struct SS{
double s;
double p;
double si;
};
int n,d;
SS pro[1010];
bool cmp(const SS &a,const SS &b){
return a.si>b.si;
}
int main(){
cin>>n>>d;
for(int i=0;i<n;i++) cin>>pro[i].s;
for(int i=0;i<n;i++) {
cin>>pro[i].p;
if(fabs(pro[i].s)<1e-9){
pro[i].si=0;
}else pro[i].si=pro[i].p/pro[i].s;
}
sort(pro,pro+n,cmp);
int i=0;
double res=0;
while(d&&i<n){
if(pro[i].s<d){
d-=pro[i].s;
res+=pro[i].p;
i++;
}else{
res+=pro[i].si*d;
d=0;
}
}
printf("%.2f\n",res);
return 0;
}
PAT1070. Mooncake (25)的更多相关文章
- PAT1070:Mooncake
1070. Mooncake (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Mooncake is ...
- PAT 甲级 1070 Mooncake (25 分)(结构体排序,贪心,简单)
1070 Mooncake (25 分) Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autum ...
- PAT 1070. Mooncake (25)
Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types ...
- 1070. Mooncake (25)
题目如下: Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many ...
- PAT Advanced 1070 Mooncake (25) [贪⼼算法]
题目 Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many typ ...
- PAT (Advanced Level) 1070. Mooncake (25)
简单贪心.先买性价比高的. #include<cstdio> #include<cstring> #include<cmath> #include<vecto ...
- PAT甲题题解-1070. Mooncake (25)-排序,大水题
#include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...
- A1070 Mooncake (25 分)
一.参考代码 #include<cstdio> #include<algorithm> #include<iostream> using namespace std ...
- 【PAT甲级】1070 Mooncake (25 分)(贪心水中水)
题意: 输入两个正整数N和M(存疑M是否为整数,N<=1000,M<=500)表示月饼的种数和市场对于月饼的最大需求,接着输入N个正整数表示某种月饼的库存,再输入N个正数表示某种月饼库存全 ...
随机推荐
- 【react读取文件】react发送GET请求读取静态文件
react中,使用发送请求的方式把static文件夹中的前端可访问的静态文件读取成字符串: 1.new request,需要用到getRequestHeaders组件 2.fetch获取respons ...
- Ant-Design如何使用
1.下载Node.js Node.js的版本需要不低于V4.x,本不在省略,如果需要出门左转Node.js安装教程. 查看Node.js版本: C:\Users\Administrator>no ...
- Linux more命令
more命令类似与cat命令,却比cat命令强大,它以全屏幕的方式按页显示文本文件的内容,支持vi中的关键字定位操作. 1.快捷键 space, z 向下翻页b,ctrl+b 向上翻页 E ...
- 如何查看windows某个目录下所有文件/文件夹的大小?
如何查看windows某个目录下所有文件/文件夹的大小? TreeSize Free绿色汉化版是一款硬盘空间管理工具,用树形描述出来,能够显示文件大小和实际占用空间数及浪费的空间等信息,让你做出相应的 ...
- python学习笔记(六)time、datetime、hashlib模块
一.hashlib模块 python中的hashlib模块用来进行hash或者md5加密,而且这种加密是不可逆的,所以这种算法又被称为摘要算法.在python3的版本里,代替了md5和sha模块,主要 ...
- Spark Streaming Checkpoint反序列化问题分析
转载自:https://mp.weixin.qq.com/s/EQgDUSf3TK0oVg1xmg-49Q Checkpoint是Spark Streaming中的核心机制,它为应用程序的7*24小时 ...
- Windows下IIS+PHP 5.2的安装与配置
Windows下IIS+PHP 5.2的安装与配置 Windows下PHP的安装虽然简单,但如果不注意方法,仍然会让你头疼.此外,PHP 5.2版本与之前4.x版本也有一些不同,所以有必要记录一下 ...
- delphi程序中定义热键
delphi程序中定义热键 用到3个API函数 BOOL RegisterHotKey ( HWND hWnd, //响应该热键的窗口句 ...
- 如何获取iClap的内测资格
iClap,一款拥有智能产品管理能力的系统,第一次遇见是在8月下旬的创新中国的展会上,茫茫人海中只因多看了你一眼,便深深的留在脑海里挥之不去,展会结束的当天就忍不住想要更多的了解你,登陆iClap官网 ...
- 哪个地图API 好用
之前我们能用的地图软件还寥寥无几,而且一个地图包动辄就上百M,还不支持GPS,没有实时路况,没有卫星图,一年也未必更新一次.现如今的地图功能已经极大丰富了,开发者的项目选择性也很大,地图哪个受众比较多 ...