public class Solution { public int FindContentChildren(int[] g, int[] s) { var listg = g.OrderBy(x => x).ToList(); var lists = s.OrderBy(x => x).ToList(); i
转载 2017-04-19 11:09:00
54阅读
转自:http://blog.csdn.net/mobius_strip/article/details/40584263//暴力,数组运用,适合小数据#include#includeusing %d", &T); while(T--){
转载 2022-10-21 16:06:53
29阅读
原题链接 描述 Assume you are an awesome parent and want to give yo
转载 2021-08-10 20:59:00
26阅读
2评论
g(i)s(...
原创 2023-06-05 16:05:37
63阅读
地址:http://codeforces.com/problemset/problem/455/A Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winte
原创 2022-09-26 16:41:54
43阅读
Periodic StringsTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluDescription Periodic ...
转载 2016-01-10 20:56:00
98阅读
2评论
原题链接 考察:线性dp(状态机dp?) 错误思路: 对于每个数字按出现次数sz与值val的乘积排序,假设第一个值为x,$x*sz[x]>(x-1)*sz[x-1]\(但这并不表明\)(x-1)*sz[x-1]+(x+1)sz[x+1]会<xsz[x]$.所以贪心是不可取的. 正确思路: 选择没有规
转载 2021-06-30 19:29:00
178阅读
2评论
  A. Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex doesn't like boredom. That's why whenever he gets bored, he comes
转载 2014-08-09 20:39:00
105阅读
2评论
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a g
转载 2018-12-01 17:17:00
41阅读
2评论
题目: Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum si
原创 2023-03-07 12:37:29
83阅读
/*Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a
原创 2021-07-09 14:05:12
92阅读
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to pl
原创 2021-07-14 15:59:56
197阅读
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a g
转载 2020-07-03 11:45:00
61阅读
假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。 对每个孩子 i,都有一个胃口值 g[i],这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 j,都有一个尺寸 s[j] 。如果 s[j] >= g[i],我们可以将这个饼干 j 分配给孩子 i ,这个孩子会得
转载 2020-12-25 12:47:00
132阅读
2评论
package LeetCode_455 /** * 455. Assign Cookies * https://leetcode.com/problems/assign-cookies/ * Assume you are an awesome parent and want to give you ...
转载 2021-08-02 16:34:00
48阅读
2评论
贪心算法:1.确定问题最优子结构2.设计递归算法3.证明贪心算法安全性4.将递归转换为迭代自己解答:class Solution(object): def findContentChildren(self, g, s): """ :type g: List[int] :type s: List[int] :rty...
原创 2022-05-23 09:39:35
49阅读
Assume you are an awesome parent and want to give your children some cookies. But, you should give
原创 2022-08-03 16:37:42
52阅读
贪心算法第一题,这里的局部最优就是大饼干给胃口大的,充分利用饼干尺寸喂饱一个,全局最优就是喂饱尽可能多的小孩。
原创 2022-12-31 00:46:41
143阅读
题目大意:求字符串的最小周期,也就是子字符串的最小长度。解题思路:两个循环,暴力解决。注意格式,可能跟“编译器偷懒”有关,改了一次,大概就是确保每次得到子字符串是自己想要的。ac代码:#include #include using namespace std;int main(){ char a[1005], b[1005], c[1005]; int n, len
原创 2021-12-01 16:27:12
55阅读
/*Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a
原创 2022-02-03 14:36:28
82阅读
  • 1
  • 2
  • 3
  • 4
  • 5