浪子不回头ぞ 提交于 2020-03-08 00:03:22
Recently Jack becomes much more romantic. He would like to prepare several bunches of flowers. Each bunch of flowers must have exactly M flowers. As Jack does not want to be boring, he hopes that flowers in the same bunch are all different species. Now there are N species of flowers in the flower shop, and the number of the i-th species of flower is a​i​​. Now Jack would like to know how many bunches of flowers he can prepare at most. (Flowers are used to propose.) Input The first line contains an integer T (1≤T≤10) --- the number of test cases. In the first line of each test case, there are

605. Can Place Flowers*

拥有回忆 提交于 2020-01-26 01:25:49
605. Can Place Flowers* 题目描述 Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. Given a flowerbed (represented as an array containing 0 and 1, where 0 means empty and 1 means not empty), and a number n , return if n new flowers can be planted in it without violating the no-adjacent-flowers rule. Example 1: Input: flowerbed = [ 1,0,0,0,1 ] , n = 1 Output: True Example 2: Input: flowerbed = [ 1,0,0,0,1 ] ,

B. Ciel and Flowers

馋奶兔 提交于 2020-01-16 03:12:54
链接: Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets: To make a "red bouquet", it needs 3 red flowers. To make a "green bouquet", it needs 3 green flowers. To make a "blue bouquet", it needs 3 blue flowers. To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower. Help Fox Ciel to find the maximal number of bouquets she can make. Input The first line contains three integers r , g and b (0 ≤  r ,  g ,  b  ≤ 109) — the

B. Pashmak and Flowers

情到浓时终转凉″ 提交于 2020-01-11 23:21:41
题目链接: 这道题是个水题,但是如果你想要暴力去做的话是不能过的。 思路: 首先我们对数组进行排序,找到最大值和最小值。然后统计最大值和最小值出现的次数,然后相乘就可以了。 但是! 如果最大值和最小值相等呢?也就是说这个数组的所以元素都是一样的,那么是不符合上述公式的。 所以我们需要特判一下。如果都相等的时候,任意取两个都符合条件,n*(n-1)/2 因为出现了相乘,所以我们还得考虑类型的转化。 int-> long long 所以这道题的坑点还是挺多的。 1 #include <iostream> 2 #include <algorithm> 3 #include <stdlib.h> 4 #include <string> 5 #include <string.h> 6 #include <set> 7 #include <queue> 8 #include <stdbool.h> 9 #include <map> 10 11 using namespace std; 12 const int MAXN=200005; 13 14 int n; 15 int a[MAXN]; 16 int vis[MAXN]; 17 18 int main() 19 { 20 #ifndef