当前位置:网站首页>分饼干问题
分饼干问题
2022-06-25 14:20:00 【我不是萧海哇~~~~】
1.分配问题
有一群孩子和一堆饼干,每个孩子有一个饥饿度,°每个饼干都有一个大小。
每个孩子只能吃最多一个饼干,且只有饼干的大小大于孩子的饥饿度时,这个孩子才能吃饱。
求解最多有多少孩子可以吃饱。
输入输出样例
输入:
1 2
1 2 3
输出:2
Code:
int solve(vector<int> &children,vector<int> &cookies)
{
sort(children.begin(),children.end());
sort(cookies.begin(),cookies.end());
int ichi=0;
int icook=0;
while(ichi<children.size()&&icook<cookies.size())
{
if(children[ichi]<cookies[icook++])ichi++;
}
return ichi;
}
边栏推荐
- Classifier and cross entropy loss function
- 移除区间(贪心)
- Where is it safe to open an account for buying funds? Ask for guidance
- [untitled] the CMD command window displays' NPM 'which is not an internal or external command
- How to choose a technology stack for web applications in 2022
- Hash table, hash conflict
- QT memory mapping
- One time summary: 64 common terms for data analysis!
- Dialogue: recommended system quick start route and summary of knowledge points
- 分类器与cross entropy loss函数
猜你喜欢

Page 112 machine learning - review of fundamentals of mathematics pptx

Variables, scopes, and variable promotion

shell 数组

Haven't you understood the microservice data architecture transaction management +acid+ consistency +cap+base theory? After reading it, you can completely solve your doubts

专家建议|8大措施加速你的创新职业规划和成长

JVM 用工具分析OOM经典案例

TSDB在民机行业中的应用

第一次读 “Clean” 系列,并没有觉得这是一本多好的书

Add the resources directory under test in idea

Deeply understand the mathematics behind deep neural networks (mysteries of neural networks Part I)
随机推荐
使用sphinx根据py源文件自动生成API文档
shell 字符串变量
关于win10 版本kicad 卡死的问题, 版本6.x
Add the resources directory under test in idea
【HBZ分享】LockSupport的使用
Jaspersoft studio installation
成员变量与局部变量的区别
H5 page graying source code, ie compatible (elegant downgrade provides download browser link)
As a software testing engineer, how do you think to ensure software quality?
[HBZ sharing] use of locksupport
广发易淘金和同花顺哪个更好,更安全一些
Thymeleaf Usage Summary
Get the parameters in the URL and the interchange between parameters and objects
Shell string variable
K-line diagram 24 classic diagrams (shadow)
‘nvidia-smi‘ 不是内部或外部命令,也不是可运行的程序或批处理文件
Jaspersoft studio adding MySQL database configuration
"Mobile cloud Cup" computing power network application innovation competition is in hot registration!
Partager les points techniques de code et l'utilisation de logiciels pour la communication Multi - clients socket que vous utilisez habituellement
关于STM32使用LAN8720A插拔网线重连