CF816B.Karen and Coffee
普及/提高-
通过率:0%
时间限制:2.50s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
To stay woke and attentive during classes, Karen needs some coffee!

Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".
She knows n coffee recipes. The i-th recipe suggests that coffee should be brewed between l__i and r__i degrees, inclusive, to achieve the optimal taste.
Karen thinks that a temperature is admissible if at least k recipes recommend it.
Karen has a rather fickle mind, and so she asks q questions. In each question, given that she only wants to prepare coffee with a temperature between a and b, inclusive, can you tell her how many admissible integer temperatures fall within the range?
为了在课堂上保持清醒和专注,凯伦需要来杯咖啡!

凯伦是一位咖啡爱好者,她想知道冲泡完美咖啡的最佳温度。事实上,她花了不少时间阅读多本食谱书,包括广受赞誉的《咖啡因艺术》(The Art of the Covfefe)。
她掌握了 n 种咖啡配方。其中第 i 种配方建议,为获得最佳风味,咖啡的冲泡温度应介于 li 到 ri 摄氏度之间(含端点)。
凯伦认为:若某温度被至少 k 种配方所推荐,则该温度是可接受的。
凯伦的思维颇为善变,因此她提出了 q 个问题。对每个问题,已知她只想用介于 a 到 b 摄氏度之间(含端点)的温度来冲泡咖啡,请你告诉她:在此温度范围内,有多少个可接受的整数温度?
输入格式
The first line of input contains three integers, n, k (1 ≤ k ≤ n ≤ 200000), and q (1 ≤ q ≤ 200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively.
The next n lines describe the recipes. Specifically, the i-th line among these contains two integers l__i and r__i (1 ≤ l__i ≤ r__i ≤ 200000), describing that the i-th recipe suggests that the coffee be brewed between l__i and r__i degrees, inclusive.
The next q lines describe the questions. Each of these lines contains a and b, (1 ≤ a ≤ b ≤ 200000), describing that she wants to know the number of admissible integer temperatures between a and b degrees, inclusive.
输入的第一行包含三个整数 n、k(1 ≤ k ≤ n ≤ 200000)和 q(1 ≤ q ≤ 200000),分别表示食谱数量、某温度被推荐的最少食谱数(即该温度为“可接受”的最低要求),以及 Karen 提出的问题数量。
接下来的 n 行描述各食谱。具体而言,其中第 i 行包含两个整数 li 和 ri(1 ≤ li ≤ ri ≤ 200000),表示第 i 个食谱建议将咖啡冲泡温度控制在 li 至 ri 摄氏度之间(含端点)。
接下来的 q 行描述各个问题。每行包含两个整数 a 和 b(1 ≤ a ≤ b ≤ 200000),表示她想知道在 a 至 b 摄氏度之间(含端点)有多少个可接受的整数温度。
输出格式
For each question, output a single integer on a line by itself, the number of admissible integer temperatures between a and b degrees, inclusive.
对于每个问题,在一行中单独输出一个整数,表示在 a 到 b 摄氏度(含端点)之间的可接受整数温度的个数。
输入输出样例
输入#1
3 2 4 91 94 92 97 97 99 92 94 93 97 95 96 90 100
输出#1
3 3 0 4
输入#2
2 1 1 1 1 200000 200000 90 100
输出#2
0
说明/提示
In the first test case, Karen knows 3 recipes.
- The first one recommends brewing the coffee between 91 and 94 degrees, inclusive.
- The second one recommends brewing the coffee between 92 and 97 degrees, inclusive.
- The third one recommends brewing the coffee between 97 and 99 degrees, inclusive.
A temperature is admissible if at least 2 recipes recommend it.
She asks 4 questions.
In her first question, she wants to know the number of admissible integer temperatures between 92 and 94 degrees, inclusive. There are 3: 92, 93 and 94 degrees are all admissible.
In her second question, she wants to know the number of admissible integer temperatures between 93 and 97 degrees, inclusive. There are 3: 93, 94 and 97 degrees are all admissible.
In her third question, she wants to know the number of admissible integer temperatures between 95 and 96 degrees, inclusive. There are none.
In her final question, she wants to know the number of admissible integer temperatures between 90 and 100 degrees, inclusive. There are 4: 92, 93, 94 and 97 degrees are all admissible.
In the second test case, Karen knows 2 recipes.
- The first one, "wikiHow to make Cold Brew Coffee", recommends brewing the coffee at exactly 1 degree.
- The second one, "What good is coffee that isn't brewed at at least 36.3306 times the temperature of the surface of the sun?", recommends brewing the coffee at exactly 200000 degrees.
A temperature is admissible if at least 1 recipe recommends it.
In her first and only question, she wants to know the number of admissible integer temperatures that are actually reasonable. There are none.
在第一个测试用例中,Karen 知道 3 个咖啡冲泡配方。
- 第一个配方建议将咖啡在 91 至 94 摄氏度(含端点)之间冲泡。
- 第二个配方建议将咖啡在 92 至 97 摄氏度(含端点)之间冲泡。
- 第三个配方建议将咖啡在 97 至 99 摄氏度(含端点)之间冲泡。
若一个温度值被至少 2 个配方所推荐,则该温度是可接受的(admissible)。
她提出了 4 个问题。
在第一个问题中,她想知道在 92 至 94 摄氏度(含端点)之间的可接受的整数温度有多少个。答案是 3:92、93 和 94 摄氏度均为可接受温度。
在第二个问题中,她想知道在 93 至 97 摄氏度(含端点)之间的可接受的整数温度有多少个。答案是 3:93、94 和 97 摄氏度均为可接受温度。
在第三个问题中,她想知道在 95 至 96 摄氏度(含端点)之间的可接受的整数温度有多少个。答案是 0(不存在)。
在最后一个问题中,她想知道在 90 至 100 摄氏度(含端点)之间的可接受的整数温度有多少个。答案是 4:92、93、94 和 97 摄氏度均为可接受温度。
在第二个测试用例中,Karen 知道 2 个配方。
- 第一个配方名为“wikiHow:如何制作冷萃咖啡”,建议将咖啡精确在 1 摄氏度下冲泡。
- 第二个配方名为“如果咖啡的冲泡温度没有达到太阳表面温度的至少 36.3306 倍,那它还有什么价值?”,建议将咖啡精确在 200000 摄氏度下冲泡。
若一个温度值被至少 1 个配方所推荐,则该温度是可接受的(admissible)。
在她的第一个且唯一一个问题中,她想知道有多少个可接受的整数温度是实际合理的。答案是 0(不存在)。
输入解题思路,AI测评打分。不知道怎么写?