1、摘要
原创 2021-08-13 09:27:53
134阅读
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re
转载 2016-07-21 05:52:00
113阅读
2评论
There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one candy.Children with a higher rating get more candies than their neighbors.What is the minimum candies you mu
转载 2013-10-03 08:55:00
128阅读
2评论
动态规划:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following ...
转载 2014-11-26 22:46:00
116阅读
2评论
There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi...
转载 2014-07-04 10:32:00
91阅读
2评论
There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi...
转载 2014-07-08 22:17:00
67阅读
2评论
/* */#include#include//#include#include using namespace std;#define STOP system("pause");#if 1class Solution {public: int candy(vector &ratings) { i...
转载 2015-10-14 19:41:00
110阅读
2评论
There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi...
转载 2014-06-25 15:58:00
130阅读
比赛总结 题目题意:有f种口味的糖果,现在要把每颗糖果分到一些packs里面去。packs分两种:flavored pack:只有一种口味。variety pack:每种口味都有。求满足下列要求的分法有多少种:1、每个pack至少有两颗糖果。2、所有pack的糖果数相同。3、variety pack 里每种口味的糖果数量相同。4、至少一个variety pack。5、每种口味至少一个flavored pack。 题解:设一个pack 的糖果数为lim。由3知lim是f的倍数。并且去掉variety packs后,剩下的每种糖果间的差值还跟原来一样,要将它们分完必须都是lim的倍数,也就是差值也
转载 2013-09-02 18:24:00
97阅读
2评论
https://oj.leetcode.com/problems/candy//***There are N children standing in a line. Each child is assigned a rating value.*You are giving candies to t...
转载 2015-07-03 15:13:00
106阅读
2评论
Question There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least
转载 2023-02-02 14:53:09
80阅读
贪心法 复杂度 时间 O(N) 空间 O(N) 思路 典型的贪心法,如果一个孩子比另一个孩子的分高,我们只多给1块糖。我们可以先从左往右遍历,确保每个孩子根他左边的孩子相比,如果分高,则糖要多1个,如果分比左边低,就只给一颗。然后我们再从右往左遍历,确保每个孩子跟他右边的孩子相比,如果分高则糖至少多
转载 2014-09-20 13:18:00
200阅读
2评论
原题链接在这里:https://leetcode.com/problems/candy/ There are N children standing in a line. Each child is assigned a rating value. You are giving candies to
转载 2015-11-05 07:52:00
74阅读
2评论
题解: 由题意得需要运用: C(m,n)=exp(logC(m,n))f[0]=0;for(int i=1; i#includedouble f[400005];double logC(int m,int n){ return f[m]-f[n]-f[m-n];}int main(){ f[0]=0; int test=0,n; double p,q,ans; for(int i=1;i<=400002;i++) f[i]=f[i-1]+log(i*1.0); while(scanf("%d %lf",&n,&p)!=EOF) { ...
转载 2013-10-30 20:52:00
94阅读
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re
i++
转载 2017-06-08 17:56:00
52阅读
2评论
目录?问题描述?解题思路?解题代码?问题描述题目描述WCB某天买了非常多的糖果并把它们分成N份,依次分
原创 2022-08-08 20:43:21
126阅读
if(ratings.empty())return 0; else if(ratings.size()==1)return 1; int sum=0; int up_Cnt=0; ...
原创 2023-01-11 12:09:13
68阅读
https://leetcode.com/problems/candy/注意思路 1. 首先为每一个孩子分配1个糖果 记当前孩子序号为i,糖果数为
原创 2023-06-29 09:57:26
24阅读
源向每个小孩连边,容量是该小孩的初始糖数; 每个小孩向汇连边,容量是糖的平均数; 每个小孩想相邻的格子各连一条边,容量是1. 把图建
原创 2023-09-15 09:46:32
49阅读
"LeetCode 135 Candy" 思路: 将数组排序。然后根据值从小到大,在数组中依次标记值。 c++
原创 2022-10-18 13:57:43
39阅读
  • 1
  • 2
  • 3
  • 4
  • 5