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个正数表示某种月饼库存全 ...
随机推荐
- Linux上的下载软件uGet
uGet是一款开源下载软件,类似于我们常用的迅雷,不过uGet支持的操作系统非常多,Ubunut,Arch,openSUSE,Windows,MacOS,BSD等. uGet支持两个下载引擎:curl ...
- MFC工具栏设计
工具栏中包含了一组用于执行命令的按钮,每个按钮都用一个图标来表示.当单击某个按钮时,会产生一个相应的消息,对这个消息的处理就是按钮的功能实现.将菜单中常用的功能放置在工具栏中,这样可以方便用户操作,省 ...
- oracle编程艺术--runstst工具
runstats工具是< oracle database 9i/10g/11g编程艺术 深入数据库体系结构>作者写的一个统计性能工具,能对做同一件事的两个方法进行比较,得到孰优孰劣的结果. ...
- HTML容易遗忘内容(二)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> ...
- (3.14) set statistics io/time/profile /SET SHOWPLAN_ALL ON详解统计信息与执行计划
SQL Server读懂语句运行的统计信息 SET STATISTICS TIME IO PROFILE ON 执行计划详细描述请参考(读懂执行计划) 对于语句的运行,除了执行计划本身,还有一些其他 ...
- 增强MyEclipse的代码自动提示功能
一般在Eclipse ,MyEclipse代码里面,打个foreach,switch等 这些,是无法得到代码提示的(不信自己试试),其他的就更不用说了,而在Microsoft Visual Stu ...
- 001-window下运行linux
一.概述 前提:有条件的情况下,自行安装 在windows上模拟linux环境,主要有三种方法: 1.VMware等虚拟机,缺点:占用系统资源多,运行速度慢. 2.Cygwin等模拟环境,用windo ...
- django高级之爬虫基础
目录: 爬虫原理 requests模块 beautifulsoup模块 爬虫自动登陆示例 一.爬虫原理 Python非常适合用来开发网页爬虫,理由如下:1.抓取网页本身的接口相比与其他静态编程语言,如 ...
- PAT 1145 Hashing - Average Search Time [hash][难]
1145 Hashing - Average Search Time (25 分) The task of this problem is simple: insert a sequence of d ...
- Cout<<XXX<<<XXX<<<XXX,是从左到右计算的
int a=1,b=2,c=3; cout<<(c=a+b)<<' '<<(a=b+c)<<' '<<(b=a+c)<<e ...