当前位置:网站首页>分饼干问题
分饼干问题
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;
}
边栏推荐
- Two methods to rollback the code in pycharm to the specified version (with screenshot)
- Sigmoid function sigmoid derivation
- 成员变量与局部变量的区别
- Mutationobserver listens for DOM changes
- JGG | 河北大学杜会龙组综述植物泛基因组学研究
- 一次性总结:64个数据分析常用术语!
- Dialogue: recommended system quick start route and summary of knowledge points
- 程序員為什麼要軟一點?
- [untitled]
- Renix Perf: IP网络性能测试工具及测试用例参数详解
猜你喜欢

分类器与cross entropy loss函数

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

How does hash eagle, the founder of equity NFT, redefine NFT and use equity to enable long-term value?

英語中的九大詞性與九大時態

重磅!国产 IDE 发布,由阿里研发,完全开源!(高性能+高定制性)

Settings the PC must be turned on

oracle数据库常用的函数总结

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

Application of TSDB in civil aircraft industry

Shell array
随机推荐
JS floating point multiplication and division method can not accurately calculate the problem
JGG | 河北大学杜会龙组综述植物泛基因组学研究
Solving error: creating window glfw error: glew initialization error: missing GL version
Shell string variable
shell 字符串变量
Two common ways for orcale to clear table data
Installation and removal of MySQL under Windows
Pourquoi les programmeurs devraient - ils être plus doux?
ffmpeg protocol concat 进行ts流合并视频的时间戳计算及其音画同步方式一点浅析
如何在 2022 年为 Web 应用程序选择技术堆栈
买基金在哪里开户安全?求指导
【世界历史】第二集——文明的曙光
JVM uses tools to analyze classic cases of OOM
shell 内置命令
Mutationobserver listens for DOM changes
Typescript and go --- essence
Let and const commands
Shell operator
【世界历史】第一集——石器时代的人们
K-line diagram 24 classic diagrams (shadow)