1070 Mooncake (25 point(s))

pat甲级什么水平_PAT&PATFEE团体报名开始啦! 2019年冬季PAT&PATFEE(甲、乙级)将于2019年12月7日13:30-16:30在浙江工业大学之江学院举行,现已开始报名啦!下面就给大家介绍一下PAT吧! PAT是什么?计算机程序设计能力考(Programming Ability Test,简称PAT)自2011年8月起创办,2018年加入信息技术新工科产学研联盟和中国软件行业协会联合发起的通用能力评测,成为... 阅读详情

1070 Mooncake (25 point(s))

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 200
180 150 100
7.5 7.2 4.5

Sample Output:

9.45

贪心。基于性价比的贪心策略,注意考虑所有的月饼馅都不够的情况(否则case#3段错误,23分)。

#include<iostream>
#include<algorithm>
using namespace std;
struct mooncake{
	double amount,price,ratio;
	bool operator < (const mooncake &other) const{
		return ratio>  other.ratio;
	}
	void calRatio(){
		ratio = price / amount;
	}
};
mooncake M[1007];
int main(void){
	int N;double D;
	cin>>N>>D;
	for(int i=0;i<N;i++) cin>>M[i].amount;
	for(int i=0;i<N;i++) cin>>M[i].price;
	for(int i=0;i<N;i++) M[i].calRatio();
	double cur = 0.0;int idx=0;double ans =0.0;
	sort(M,M+N);
	while(cur<D&&idx<N){
		if(D-cur>=M[idx].amount){
			ans+=M[idx].price;
			cur+=M[idx].amount;
		}
		else{
			ans+=(D-cur)*M[idx].ratio;
			cur = D;
		}
		idx++;
	}
	printf("%.2f\n",ans);
	return 0;
	
	
}

 

2026终极反反爬:Canvas/WebGL/字体指纹全维度伪装,应对浏览器检测实战指南 本文分享了2026年浏览器指纹检测现状及全维度伪装方案。当前反爬系统采用多维度联合指纹检测,重点针对硬件级(WebGL、Canvas)、系统级(字体、CPU)和行为级(鼠标移动)指纹。作者设计了一个独立的指纹伪装引擎,包含真实设备指纹库、指纹生成器和统一注入层,通过JS沙箱隔离实现伪装。核心方案包括:Canvas指纹通过真实设备渲染差异添加微偏移;WebGL指纹完整劫持上下文返回真实显卡参数;字体指纹劫持measureText方法模拟不同系统字体宽度。该方案实测可连续运行一个月零封号,解决了传统方法易被检测 阅读详情

相关推荐

OpenClaw 3.13 + Mac mini M4 集成 qmd 记忆存储:qmd embed 卡死 / 报错 sqlite-vec 不可用 终极解决教程

模型加速让 qmd 从国内镜像下载模型,避免网络超时;SQLite 扩展支持:修改 qmd 源码后,Bun 不再使用内置 SQLite,而是调用 Homebrew 安装的,该版本支持接口,可正常加载vec0.dylib向量扩展;OpenClaw 3.13 适配:核心逻辑与 OpenClaw 3.13 的 qmd 记忆调用逻辑完全兼容,无需额外调整;sqlite-vec 加载:qmd 自动通过sqlite-vec包获取vec0.dylib路径,调用完成向量扩展加载,实现高效向量搜索。

wuanxionglidui的博客 1305

PAT甲级1070(月饼)

1070 Mooncake (25 point(s)) 题目原文   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 acco...

云胡的博客 229

MATLAB 设置legend加标题

x1 = linspace(0,5); y1 = sin(x1/2); plot(x1,y1) hold on x2 = [0 1 2 3 4 5]; y2 = [0.2 0.3 0.6 1 0.7 0.6]; scatter(x2,y2,'filled') hold off legend({'sin(x/2)','2016'},'Location','northwest','Orientation','horizontal')%水平 legend添加标题 lgd = legend; lgd.Fon

早起CaiCai的学习空间 4714

【PAT_Python解】1070 结绳

多学习其他大佬的AC代码!

新时代先锋的博客 577

从光斑图到锤形优化:一次搞定Zemax双胶合透镜的像散与场曲问题

本文详细解析了Zemax双胶合透镜设计中像散与场曲问题的诊断与优化方法。从光斑图分析到锤形优化技巧,提供了完整的光学设计实战指南,帮助设计师快速定位问题并有效改善系统性能,特别适合光学设计工程师和Zemax使用者参考。

weixin_27134495的博客 234

电子科技大学计算机预推免(最终去向)

电子科技大学,预推免报名时必须要有一封本校老师写的推荐信,推荐信基本上就是复试的入场券,所以一定要提前联系老师,拿到推荐信。只要有机会进了面试,我觉得老师对于双非并不歧视,面试的个人表现才是关键性决定因素,技巧性也是很强的,如果有需要帮助的,欢迎私信~~

D1379951481的博客 3368

PAT-1070 Mooncake

1070 Mooncake(25 分) 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 r...

Eric的博客 361

Windows 11 安装 MySQL 8.4:安装包方式、下载、安装、使用

本文详细介绍了在 Windows 11 系统下通过 MSI 安装包方式安装 MySQL 8.4 LTS 社区版的完整流程,包括版本选择、下载、自定义安装路径、服务配置、日志设置、示例数据库创建及后续使用方法。同时提供了命令行客户端与图形化工具 DBeaver 的连接与操作演示,适合初学者和开发者快速搭建本地 MySQL 开发环境。

寒水馨 · 轻量级技术文档 · hanshuixin.org 2265

第五届趣味编程比赛-苗童大作战之亲友团(求一个数组内任意两个整数相加都是素数的一个最大集合)

Description 在开始比赛前,童童决定邀请她的亲友团来给自己打气,童童的最多可以邀请 n 个人,可是其中有些人与其他人关系不太好,要知道内部不和可是会出大问题的。为了打造一个融洽的亲友团,童童都快急哭了。 这里我们用一个数组 a 表示童童的将要邀请的名单,如果 a[i] + a[j](i != j) 为素数,则表示第 i 个人和第 j 个人相处融洽,否则代表他们关系不好,你能告诉...

Akatsuki 812

AutoSAR MemMap模块详解及使用注意事项

在本文中,我们将深入探讨MemMap模块的实例解析,并介绍在使用该模块时需要注意的一些事项。在上述代码中,我们使用了MEMMAP_START_SEC_VAR_32BIT和MEMMAP_START_SEC_CODE来定义MemMap区域的起始位置,使用MEMMAP_STOP_SEC_VAR_32BIT和MEMMAP_STOP_SEC_CODE来定义MemMap区域的结束位置。1.合理划分MemMap区域:根据实际需求,合理划分MemMap区域,将不同类型的变量放置在不同的区域中,以便于管理和访问。

weixin_50547796的博客 2534

YoloV8优化:感受野注意力卷积运算(RFAConv),效果秒杀CBAM和CA等 | 即插即用系列

感受野注意力卷积运算(RFAConv),解决卷积块注意力模块(CBAM)和协调注意力模块(CA)只关注空间特征,不能完全解决卷积核参数共享的问题

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 4266

腾讯云短信发送失败提示1038错误

公司最近要做个短信通知,申请了腾讯云后添加模板如下: 尊敬的客户,您好。您正在进行{1}电子签名,请确认系本人操作,验证码{2} 第一个参数是客户的姓名,第二个参数是验证码。发送短息失败 1038错误码------验证码类模版,模版变量只能传入0 - 6位(包括6位)纯数字 我打电话问腾讯云客服,客服告诉我验证码类短信只能传入数字,不能传入汉字和其他非数字的字符。 但是与我们合作的公司使用腾讯云...

老刀 3226

SAP S/4HANA Public Cloud 的 Development Tenant 深度解析

在传统的 SAP On-Premise 版本中,企业通常拥有完整的开发、测试、生产环境,开发人员可以直接访问 ABAP 代码,进行深度定制。然而,S/4HANA Public Cloud 采用了标准化的 SaaS 模型,不允许用户直接修改核心代码。因此,SAP 提供了一种新的开发方式,即 Development Tenant,允许企业在不破坏核心系统稳定性的前提下,实现个性化扩展。Development Tenant 主要用于 SAP S/4HANA Public Cloud 的扩展开发。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 849

1070 Mooncake (25 point(s))

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 ...

张蔡辉 216

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

1070 Mooncake (25 point(s))

题解 贪心。求利润最高。只需按price / amount从大到小选择。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;algorithm&gt; #include&lt;vector&gt; using namespace std; struct node { float mount, price, avg; ...

徐伯莱 259

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

PTA甲级1070 Mooncake (25point(s))

首先,先贴柳神的博客 https://www.liuchuo.net/ 这是地址 想要刷好PTA,强烈推荐柳神的博客,和算法笔记 文章目录题目原文Input Specification:Output Specification:Sample Input:Sample Output:生词如下:题目大意:思路如下:注意点:代码如下 题目原文 1070 Mooncake (25point(s)) Moo...

Huangpengyu123的博客 289

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

1070 Mooncake (25point(s))

文章目录问题解决方法 问题 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...

weixin_43725617的博客 152

1070 Mooncake (25point(s)) - C语言 PAT 甲级

* 利用循环找到单价最高的月饼出售,直到满足市场最大需求量

有三只土豆 175

PAT----A1070 Mooncake (25point(s))

A1070 Mooncake (25point(s)) 题意 给出N中月饼的数量和总的价格,市场需求量,求最大利润 思路 简单贪心。 总结 数量和价格都有可能是浮点型,虽然数量在样例是整形。 Sample Input: 3 200 180 150 100 7.5 7.2 4.5 Sample Output: 9.45 #include"bits/stdc++.h" using namespa...

qq_43578870的博客 176

PAT_甲级_1070 Mooncake (25point(s)) (C++)【签到题/结构体排序】

1,题目描述 2,思路 3,AC代码 #include<bits/stdc++.h> using namespace std; struct node{ float amount, price, pre; }; bool cmp1(node a, node b){ return a.pre > b.pre;//性价比高 } int m...

&再见萤火虫&的博客 303

【1070】Mooncake (25 分)

#include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> #include<map> #include<vector> #inclu...

发现问题,并解决问题,批判性思维 728

PAT甲级真题 1070 Mooncake (25分) C++实现(同乙级1020,简单贪心法)

题目 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. N...

zhang35的博客 375

PAT甲级 1070 Mooncake (25 分)

\quad将月饼按照每吨的价格从大到小排序,之后每次从价格高的开始取,若剩下的总重量大于当前月饼重量,则全部取,否则取当前剩余总重量对应当前月饼的价格并退出。程序如下: #include <bits/stdc++.h> using namespace std; struct Cake { float w, p, pp; }cake[1010]; bool cmp(const Ca...

qq_40438165的博客 1722

PAT(贪心)——1070. Mooncake (25)

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 regions culture. Now g...

WangXin Programmer 179

pat甲级考试报名费_15天0基础考PAT甲级

十五天前决定跨考计算机,本科中流985,专业四大劝退之环,然后看了五天C,看到循环的样子,然后十天前看到PAT甲级考试,我在想既然十二月要去考,何不这十天冲一把去考一次,然后十天学完C剩余部分还有C++关于字符串的输入输出还有数据结构的线性表树图。我是按照晴神笔记学的,学了一遍,动态规划及以后的没看,所以今天第一题凉了。题库大概刷了八九十道,近四年的,还有晴神练习册里的部分习题。说说今天考试吧,第...

weixin_39946798的博客 1634

pat甲级考试报名费_PAT(甲级)2019年冬季考试 题解

总结写在前头:考了字符串、链表(伪链表)、图、树。考点比较均衡。本次考试难度还行,需要较扎实的数据结构底子,对于字符串处理的技巧有一定的要求。说句题外话,字符串是个重点,主要因为很多人会忽视字符串。2018-2019年的GPLT(团体程序设计天梯赛)的l1最后一题就是一道字符串处理,当时卡住了不知道多少人,但其实稍微做做字符串的题目之后就会发现,那题不过如此。这次PAT甲级的第一题也是不...

weixin_39928686的博客 1289
上一篇: 1095 Cars on Campus (30 point(s))
下一篇: 1071 Speech Patterns (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值