思路:

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

实现:

 #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. 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 ...

  2. golang 跨平台编译——go 在windows上编译Linux平台的程序(Cross Compilation from Windows to Linux/Ubuntu)

    Go Cross Compilation from Windows to Linux/Ubuntu I have GO 1.7 installed on my Windows 10. I create ...

  3. jQuery—— jQuery get方法+一般处理程序处理文本框内容

    网上常常看到这种交互方式,当去一个站点注冊username的时候,假设文本框内没有输入数据,或者数据输入的内容格式不正确.就会将文本框变成红色来提示你输入的内容有误. 自己将这个文本框验证的方式改变了 ...

  4. HDU 4869 Turn the pokers (2014多校联合训练第一场1009) 解题报告(维护区间 + 组合数)

    Turn the pokers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  5. jq 常用手册

    1.替换标签 $("img[src='/_layouts/images/lstbulet.gif']").attr("src", "/huadong/ ...

  6. onenstack 简介

    一.云计算的前世今生 所有的新事物都不是突然冒出来的,都有前世和今生.云计算也是IT技术不断发展的产物. 要理解云计算,需要对IT系统架构的发展过程有所认识. 请看下 IT系统架构的发展到目前为止大致 ...

  7. php把时间计算成几分钟前,几小时前,几天前的函数

    function time_tran($the_time){ $now_time = date("Y-m-d H:i:s",time()+8*60*60); $now_time = ...

  8. 【OI】线性筛

    如何查找一个范围内的所有素数? 可以是从1~n挨个判断n%i 是否 == 0,也可以从 1~sqr(n) 一个个判断. 相信你们也听说过埃氏筛法,是使用每一个数的倍数筛掉合数!但是!每一个合数要被筛多 ...

  9. HDU 5979 Convex【计算几何】 (2016ACM/ICPC亚洲区大连站)

    Convex Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  10. Ubuntu下Zabbix服务器监控工具部署

    Ubuntu下Zabbix服务器监控工具部署 一 安装安装Apache.Mysql.Php.zabbix sudo apt-get update sudo apt-get install apache ...