当前位置:网站首页>分饼干问题
分饼干问题
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;
}
边栏推荐
- Laravel8 implementation of picture verification code
- 合宙Air32F103CBT6开发板上手报告
- Partager les points techniques de code et l'utilisation de logiciels pour la communication Multi - clients socket que vous utilisez habituellement
- How does hash eagle, the founder of equity NFT, redefine NFT and use equity to enable long-term value?
- 中国电池技术取得重大突破,日韩美都落后了,中国巩固了领先优势
- JGG | overview of duhuilong group of Hebei University Research on plant pan genomics
- Shell built-in commands
- 还没弄明白微服务数据架构事务管理+ACID+一致性+CAP+BASE理论吗,看完彻底解决疑惑
- Common formatting methods for amount numbers
- How to choose a technology stack for web applications in 2022
猜你喜欢

两种方法实现pycharm中代码回滚到指定版本(附带截图展示)

shell 字符串变量

TSDB在民机行业中的应用

Two methods to rollback the code in pycharm to the specified version (with screenshot)

多台云服务器的 Kubernetes 集群搭建

The best screenshot tool in the world, color absorption tool snipaste

JVM uses tools to analyze classic cases of OOM

当了六年程序员第一次搞懂微服务架构的数据一致性,真不容易

oracle数据库常用的函数总结

Partager les points techniques de code et l'utilisation de logiciels pour la communication Multi - clients socket que vous utilisez habituellement
随机推荐
JS floating point multiplication and division method can not accurately calculate the problem
Suanli & NFT trading platform f3 The exclusive NFT project of XYZ, hash eagle, will be grandly launched
Logistic Regression VS Linear Regression
Laravel8 implementation of picture verification code
How to choose a technology stack for web applications in 2022
Is qiniu regular? Is it safe to open a stock account?
2020-03-20
Getting started with numpy Library
None of the MLIR Optimization Passes are enabled (registered 2)解决办法
Golang project dependency management tool go vendor, go Mod
What is the safest app for stock account opening? Tell me what you know
Shell built-in commands
To make pytorch faster, you need to master these 17 methods
sigmoid函数sigmoid求导
JS functions
112页机器学习-数学基础回顾.pptx
JS get the height and width corresponding to the box model (window.getcomputedstyle, dom.getboundingclientrect)
Page 112 machine learning - review of fundamentals of mathematics pptx
重磅!国产 IDE 发布,由阿里研发,完全开源!(高性能+高定制性)
New good friend Pinia, leading the new era of state management