static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
int findContentChildren(vector<int>& g, vector<int>& s)
{
int szchild=g.size();
int szcookies=s.size();
if(szchild==||szcookies==)
return ;
sort(g.begin(),g.end());
sort(s.begin(),s.end());
int indexchild=,indexcookies=;
int count=;
while(indexchild<szchild&&indexcookies<szcookies)
{
if(s[indexcookies]>=g[indexchild])
{
count++;
indexcookies++;
indexchild++;
}
else
indexcookies++;
}
return count;
}
};

排个序,俩数组元素扫描比较即可。

455. Assign Cookies的更多相关文章

  1. LeetCode:455. Assign Cookies

    package Others; import java.util.Arrays; //Question 455. Assign Cookies /* Assume you are an awesome ...

  2. 【leetcode】455. Assign Cookies

    problem 455. Assign Cookies solution1: But, you should give each child at most one cookie. 对小朋友的满意程度 ...

  3. 455. Assign Cookies - LeetCode

    Question 455. Assign Cookies Solution 题目大意:数组g的大小表示有几个小孩,每个元素表示小孩的食量,数组s的大小表示有多少个饼干,每个元素的大小表示每个饼干的大小 ...

  4. 12. leetcode 455.Assign Cookies

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  5. LeetCode 455. Assign Cookies (分发曲奇饼干)

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  6. 455. Assign Cookies.md

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  7. [LeetCode&Python] Problem 455. Assign Cookies

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  8. LeetCode 455. Assign Cookies (C++)

    题目: Assume you are an awesome parent and want to give your children some cookies. But, you should gi ...

  9. [leetcode greedy]455. Assign Cookies

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  10. 455. Assign Cookies 满足欲望 分配饼干

    [抄题]: Assume you are an awesome parent and want to give your children some cookies. But, you should ...

随机推荐

  1. 使用promise方式来获取网络数据

    获取网络数据 let data = []; new Promise(function(resolve,reject){ axios.post('api.php').then(function(resp ...

  2. nexus docker 私有镜像处理

    新版本的nexus 可以进行docker 镜像的存储处理 配置私有镜像(host 模式) 修改docker 非安全镜像处理 { "registry-mirrors": [" ...

  3. 提高ASP.NET页面载入速度的方法

    前言 本文是我对ASP.NET页面载入速度提高的一些做法,这些做法分为以下部分: 目录 1.采用 HTTP Module 控制页面的生命周期. 2.自定义Response.Filter得到输出流str ...

  4. Java常用基础代码

    1.加载properties文件 Properties properties = new Properties();  properties.load(Properties.class.getReso ...

  5. LoadRunner安装+破解+汉化

    安装 一.需要准备的东东: 1.电脑的操作系统:Win7旗舰版(不解释,这个版本安装问题最少了) 2.LoadRunner11+破解文件+汉化文件+删除注册表工具 3.强大的搜索引擎 二.安装过程 用 ...

  6. JpGraph使用详解

    微信平台开发的推广支持应用里,为了满足用户渠道推广分析的需要,公众平台提供了生成带参数二维码的接口.使用该接口可以获得多个带不同场景值的二维码,用户扫描后,公众号可以接收到事件推送,借此可以通过统计不 ...

  7. ASP/ASP.NET/VB6文件上传

    1. asp asp 上传文件真的蛋疼,很麻烦,有时候就用第三方组件,或者比较复杂的写法来实现无组件上传. 测试OK的一个叫风声无组件上传类 V2.1 [Fonshen UpLoadClass Ver ...

  8. Renesas PPP Mode

    不同厂家的NB/4G/2G,配置PPP模式略有差异,回调配置在如下路径: “synergy\ssp_supplemental\src\framework\sf_cellular_cat3\sf_cel ...

  9. 常用数据结构的功能及复杂度总结(OI)

    不定长数组 维护一个序列 在末尾插入/删除均摊O(1) 任意位置插入O(n) 指定位置查询/修改O(1) 空间O(n) 链表 维护一个序列 定位到第i个位置O(n) 在任意位置(已定位到该位置)插入/ ...

  10. java.lang.NumberFormatException:For input string:"undefined"

    在将字符串转换为数字时导致此错误,解决此问题的思路: 1.添加 try catch语句 2.判断字符串是否为数字,将介绍java中判断字符串是否为数字的方法的几种方法 发生错误的代码: java.la ...