2 shunfurh shunfurh 于 2017.08.29 19:21 提问

Flowers

Problem Description
As is known to all, the blooming time and duration varies between different kinds of flowers. Now there is a garden planted full of flowers. The gardener wants to know how many flowers will bloom in the garden in a specific time. But there are too many flowers in the garden, so he wants you to help him.

Input
The first line contains a single integer t (1 <= t <= 10), the number of test cases.
For each case, the first line contains two integer N and M, where N (1 <= N <= 10^5) is the number of flowers, and M (1 <= M <= 10^5) is the query times.
In the next N lines, each line contains two integer Si and Ti (1 <= Si <= Ti <= 10^9), means i-th flower will be blooming at time [Si, Ti].
In the next M lines, each line contains an integer Ti, means the time of i-th query.

Output
For each case, output the case number as shown and then print M lines. Each line contains an integer, meaning the number of blooming flowers.
Sample outputs are available for more details.

Sample Input
2
1 1
5 10
4
2 3
1 4
4 8
1
4
6

Sample Output
Case #1:
0
Case #2:
1
2
1

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.13 08:29
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Codeforces 459B Pashmak and Flowers(水题)
题目链接:Codeforces 459B Pashmak and Flowers 题目大意:找出序列中差值最大的值,并且输出有多少种选择方案。 解题思路:将数组排序,最大值减去最小值即使差值最大值,统计最大值个数和最小值个数,相乘即使答案。注意全都相同的情况,为C(2n),并且总数会爆int。 #include #include #include using namespac
leetcode -- 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.
POJ 3262 Protecting the Flowers(贪心,需要小小优化一下)
 Protecting the Flowers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5692 Accepted: 2237 Description Farmer John went to cu
Can Place Flowers:数组相邻元素不为0的插入问题
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. Gi
LeetCode 605.Can Place Flowers
class Solution { public: bool canPlaceFlowers(vector& flowerbed, int n) { int size = flowerbed.size(); vector buffer; int buffer_num = 0; int count = 0; bool flag = true; if(size>1){ if (fl
hdu4614Vases and Flowers(线段树,段设置,更新时范围的右边值为变量)
Problem Description   Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one
Tensorflow创建和读取17flowers数据集
近期开始学习tensorflow,看了很多视频教程以及博客,大多数前辈在介绍tensorflow的用法时都会调用官方文档里给出的数据集,但是对于我这样的小白来说,如果想训练自己的数据集,自己将图片转换成可以输入到网络中的格式确实是有难度。但如果不会做图片的预处理,迈不出这一步,今后的学习之路会越来越难走,所以今天还是硬着头皮把我这几天已经实现的部分做一个总结。主要参考了一篇博客,文章最后有链接,通
HDU 1587 Flowers【简单题】
/* 中文题目 中文翻译-大意 题目大意: 解题思路: 难点详解: 关键点: 解题人: 解题时间: 解题体会: */ Flowers Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2
Codeforces 451E Devu and Flowers(容斥原理)
题目链接:Codeforces 451E Devu and Flowers 题目大意:有n个花坛,要选s支花,每个花坛有f[i]支花。同一个花坛的花颜色相同,不同花坛的花颜色不同,问说可以有多少种组合。 解题思路:2n的状态,枚举说那些花坛的花取超过了,剩下的用C(n−1sum+n−1)隔板法计算个数,注意奇数的位置要用减的,偶数的位置用加的,容斥原理。 #include #inc
17flowers图片数据集
17flowers图片数据集,共17种花的类别,每种花有80张jpg图片 按花的类别整理17个子文件夹