#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h> using namespace std;
/*
3 0
180 150 100
7.5 7.2 4.5
*/
const int maxn=+;
int amounts[maxn];
float price[maxn]; struct Cake{
float amounts; //注意,这里得设置成浮点型,若是int一个样例会过不了
float price;
float unitprice=;
bool operator<(const Cake tmp)const{
return unitprice>tmp.unitprice;
}
}cake[maxn];
int main()
{
int n,d;
scanf("%d %d",&n,&d);
for(int i=;i<n;i++){
scanf("%f",&cake[i].amounts);
}
for(int i=;i<n;i++){
scanf("%f",&cake[i].price);
cake[i].unitprice=cake[i].price/cake[i].amounts;
}
sort(cake,cake+n);
float ans=;
for(int i=;i<n;i++){
if(d>=cake[i].amounts){
ans+=cake[i].price;
d-=cake[i].amounts;
}
else{
ans+=(d/cake[i].amounts)*cake[i].price;
break;
}
}
printf("%.2f",ans);
return ;
}

PAT甲题题解-1070. Mooncake (25)-排序,大水题的更多相关文章

  1. PAT甲题题解-1032. Sharing (25)-链表水题

    #include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...

  2. PAT 甲级 1070 Mooncake (25 分)(结构体排序,贪心,简单)

    1070 Mooncake (25 分)   Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autum ...

  3. PAT甲题题解-1012. The Best Rank (25)-排序水题

    排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...

  4. PAT甲题题解-1062. Talent and Virtue (25)-排序水题

    水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...

  5. PAT甲题题解-1010. Radix (25)-二分搜索

    题意:给出n1和n2,以及其中一个数的进制,问另一个数是多少进制的情况下,才会是两个数相等.不存在的话,则输出Impossible 这题思路很简单,但是要考虑的比较多,在简单题里面算是比较好的. 有两 ...

  6. PAT甲题题解-1003. Emergency (25)-最短路径+路径数目

    给出n个城市,m条边,起始点c1和目的点c2接下来给出n个城市的队伍数以及m条双向边问你求c1到c2的所有最短路径数目,以及其中经过的最多队伍数 先最短路dijkstra,同时建立vector数组pr ...

  7. PAT甲题题解-1029. Median (25)-求两序列的中位数,题目更新了之后不水了

    这个是原先AC的代码,但是目前最后一个样例会超内存,也就是开不了两个数组来保存两个序列了,意味着我们只能开一个数组来存,这就需要利用到两个数组都有序的性质了. #include <iostrea ...

  8. PAT甲题题解-1078. Hashing (25)-hash散列

    二次方探测解决冲突一开始理解错了,难怪一直WA.先寻找key%TSize的index处,如果冲突,那么依此寻找(key+j*j)%TSize的位置,j=1~TSize-1如果都没有空位,则输出'-' ...

  9. PAT 1070. Mooncake (25)

    Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival.  Many types ...

随机推荐

  1. windows 2012 抓明文密码方法

    windows 2012 抓明文密码方法 默认配置是抓不到明文密码了,神器mimikatz显示Password为null Authentication Id : 0 ; 121279 (0000000 ...

  2. Oracle RMAN 恢复数据库到不同主机(一)

    一.RMAN 备份的内容 RMAN做数据库全备时包含了 数据文件.归档日志.控制文件和参数文件和备份日志,如下: arch_20160223_08qukp2t_1_1  arch_20160223_0 ...

  3. Arthas开源项目

    本文主要围绕着Arthas是什么.能做什么.安装和使用等三个方面内容来讲解,希望对初学者和对此有兴趣的朋友有帮助. 一. Arthas是什么 文档地址: https://alibaba.github. ...

  4. <Android 开源库> PhotoPicker 从头到脚

    1. 简介 PhotoPicker, 是一款开源的图片选择器.效果上和微信相似. 2. 使用方法 2.1 添加依赖 dependencies { compile 'me.iwf.photopicker ...

  5. ssl,proxy;部分http部分https;80,443,8080;nginx+tomcat;

    ..... user nobody; worker_processes 8; error_log /opt/logs/nginx/nginx_error.log crit; pid /usr/loca ...

  6. linux服务器关闭ipv6 方法

    第一个文件: /etc/sysconfig/network 第二个文件:如无此文件,vim添加 /etc/modprobe.d/disable_ipv6.conf

  7. WorldWind源码剖析系列:图像助手类ImageHelper

    图像助手类ImageHelper封装了对各种图像的操作.该类类图如下. 提供的主要处理方法基本上都是静态函数,简要描述如下: public static bool IsGdiSupportedImag ...

  8. C++ 虚函数的使用

    虚函数是C++中用于实现多态(polymorphism)的机制.核心理念就是通过基类访问派生类定义的函数.假设我们有下面的类层次: #include <iostream> using na ...

  9. 【小程序】访问 https配置的数据接口

    小程序对于网络请求的URL的特殊要求:1)不能出现端口号;    2)不能用localhost;       3)  必须用https (一)搭建本地https服务器(windows) 搭建出来的服务 ...

  10. struts2_文件上传的功能

    使用Struts内置的fileUpload拦截器(已默认配置)即可,设计的电商网站,提供用户头像上传的功能 1. 2. 3. 4. 5. 5.未使用拦截器 6.未使用filename 7. 8. 9.