博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1070. Mooncake (25)
阅读量:4948 次
发布时间:2019-06-11

本文共 2132 字,大约阅读时间需要 7 分钟。

Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now given the inventory amounts and the prices of all kinds of the mooncakes, together with the maximum total demand of the market, you are supposed to tell the maximum profit that can be made.

Note: partial inventory storage can be taken. The sample shows the following situation: given three kinds of mooncakes with inventory amounts being 180, 150, and 100 thousand tons, and the prices being 7.5, 7.2, and 4.5 billion yuans. If the market demand can be at most 200 thousand tons, the best we can do is to sell 150 thousand tons of the second kind of mooncake, and 50 thousand tons of the third kind. Hence the total profit is 7.2 + 4.5/2 = 9.45 (billion yuans).

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 positive integers N (<=1000), the number of different kinds of mooncakes, and D (<=500 thousand tons), the maximum total demand of the market. Then the second line gives the positive inventory amounts (in thousand tons), and the third line gives the positive prices (in billion yuans) of N kinds of mooncakes. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print the maximum profit (in billion yuans) in one line, accurate up to 2 decimal places.

Sample Input:

3 200180 150 1007.5 7.2 4.5

Sample Output:

9.45
#include
#include
#include
#include
#include
using namespace std;struct Node{ double perprice; double amount; double money;};bool cmp(Node a, Node b){ return a.perprice>b.perprice;}int main(){ int i,j; int N,D; scanf("%d%d",&N,&D); vector
node; node.resize(N); for(i=0;i
=node[i].amount){ D-=node[i].amount; sum+=node[i].money; }else { sum+=node[i].money*D*1.0/node[i].amount; D=0; } i++; if(i>=N)break; } printf("%.2lf\n",sum); return 0;}

  

 

转载于:https://www.cnblogs.com/grglym/p/7856108.html

你可能感兴趣的文章
ASP.NET中 GridView(网格视图)的使用前台绑定
查看>>
图像加载
查看>>
关于zxing生成二维码,在微信长按识别不了问题
查看>>
Haskell学习-高阶函数
查看>>
手动通知扫描SD卡主动生成缩略图
查看>>
js中tagName和nodeName
查看>>
PC-XP系统忘记密码怎么办
查看>>
Android实例-打电话、发短信和邮件,取得手机IMEI号(XE8+小米2)
查看>>
深入了解Oracle ASM(二):ASM File number 1 文件目录
查看>>
SQL数据库学习系列之一
查看>>
Boosting(提升方法)之AdaBoost
查看>>
CUDA学习1 在Visual Studio和CodeBlocks上配置
查看>>
JavaScript(6)——事件1.0
查看>>
2013 ACM-ICPC China Nanjing Invitational Programming Contest 总结
查看>>
【Hibernate学习笔记-5】@Formula注解的使用
查看>>
链接元素<a>
查看>>
Binding object to winForm controller through VS2010 Designer(通过VS2010设计器将对象绑定到winForm控件上)...
查看>>
Spring Boot实战笔记(二)-- Spring常用配置(Scope、Spring EL和资源调用)
查看>>
前端性能优化集【持续更新】
查看>>
第二章:webdriver 控制浏览器窗口大小
查看>>