思路:

有点类似于区间修改点查询的树状数组。

实现:

 #include <iostream>
#include <cstdio>
using namespace std; const int MAXN = ;
int a[MAXN], n, k, q; int main()
{
cin >> n >> k >> q;
for (int i = ; i < n; i++)
{
int l, r;
scanf("%d %d", &l, &r);
a[l]++; a[r + ]--;
}
for (int i = ; i < MAXN; i++) a[i] += a[i - ];
for (int i = ; i < MAXN; i++)
if (a[i] >= k) a[i] = ;
else a[i] = ;
for (int i = ; i < MAXN; i++) a[i] += a[i - ];
for (int i = ; i < q; i++)
{
int l, r;
scanf("%d %d", &l, &r);
printf("%d\n", a[r] - a[l - ]);
}
return ;
}

CF816B Karen and Coffee的更多相关文章

  1. B. Karen and Coffee

    B. Karen and Coffee time limit per test 2.5 seconds memory limit per test 512 megabytes input standa ...

  2. CodeForces 816B Karen and Coffee(前缀和,大量查询)

    CodeForces 816B Karen and Coffee(前缀和,大量查询) Description Karen, a coffee aficionado, wants to know the ...

  3. codeforces round #419 B. Karen and Coffee

    To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...

  4. Karen and Coffee CodeForces - 816B (差分数组+预处理前缀和)

    To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...

  5. Codeforces Round #419 (Div. 2) B. Karen and Coffee

    To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...

  6. Codeforces816B Karen and Coffee 2017-06-27 15:18 39人阅读 评论(0) 收藏

    B. Karen and Coffee time limit per test 2.5 seconds memory limit per test 512 megabytes input standa ...

  7. Codeforces Round #419 (Div. 2) B. Karen and Coffee(经典前缀和)

    http://codeforces.com/contest/816/problem/B To stay woke and attentive during classes, Karen needs s ...

  8. Karen and Coffee CF 816B(前缀和)

    Description To stay woke and attentive(专注的) during classes, Karen needs some coffee! Karen, a coffee ...

  9. CF 816B Karen and Coffee【前缀和/差分】

    To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...

随机推荐

  1. MySQL使用教程收集(语法教程/命令教程)

    说明:现在市面上的教程除了基本语法外,都基本是五花八门的,最权威且最全面的解释应该上官网去查看. https://www.tutorialspoint.com/mysql/index.htm http ...

  2. cn_windows_10_multiple_editions_version_1607_updated_jul_2016_x64

    ed2k://|file|cn_windows_10_multiple_editions_version_1607_updated_jul_2016_x64_dvd_9056935.iso|43471 ...

  3. symfony could not load type 'datetime'

    当用curd生成控制器后,当修改的时候,会有这个提示,解决方法 在orm中通过事务的方式填充时间,然后把生成的form中的文件的时间段去掉 $builder ->add('title') -&g ...

  4. 用pc构建DIY计算集群

    -----------------------------------------------------------------用pc构建DIY计算集群目录/构建计算集群|-- /0前言|-- /1 ...

  5. 剑指Offer - 开始没做出来 —— 验证后序序列是否正确

    https://www.nowcoder.net/practice/a861533d45854474ac791d90e447bafd?tpId=13&tqId=11176&tPage= ...

  6. Java之旅hibernate(2)——文件夹结构

    Hibernate的jar最好是到官网上进行下载.下载最新的稳定的版本号.之后进行解压,以下我们介绍一下hibernate的包结构. 1.      包结构 我们能够看到包文件夹结构发生了变化.我以5 ...

  7. js_html_input中autocomplete="off"在chrom中失效的解决办法 使用JS模拟锚点跳转 js如何获取url参数 C#模拟httpwebrequest请求_向服务器模拟cookie发送 实习期学到的技术(一) LinqPad的变量比较功能 ASP.NET EF 使用LinqPad 快速学习Linq

    js_html_input中autocomplete="off"在chrom中失效的解决办法 分享网上的2种办法: 1-可以在不需要默认填写的input框中设置 autocompl ...

  8. Nginx + FastCgi + Spawn-fcgi + C 架构的server环境搭建

    1.Nginx 1.1.安装 Nginx 的中文维基 http://wiki.codemongers.com/NginxChs 下载 Nginx 0.6.26(开发版)(请下载最新版本号) tar z ...

  9. tomcat的HTTPS

    完美配置Tomcat的HTTPS 博客分类: Tomcat HTTPS   Tomcat配置HTTPS的文章到处都有,过程也比较简单,随后文中会转一段过来. 但对于启用APR情况下报异常“java.l ...

  10. Rational 最新软件试用下载地址

    看到非常多 TX 都在问老版本号 Raitonal 软件相关的问题,可是因为产品升级的时候有非常多名字都发生了更改(比方说 Rational Rose 最新的版本号变成了 Rational Softw ...