思路:

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

实现:

 #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. 18.9.23 PION模拟赛

    U32670 小凯的数字 题目背景 NOIP2018 原创模拟题T1 NOIP DAY1 T1 or DAY 2 T1 难度 是否发现与NOIP2017 DAY1 T1 有异曲同工之妙 说明:#10, ...

  2. mysql建表语句key的含义

    CREATE TABLE `admin_role` (  `adminSet_id` varchar(32) NOT NULL,  `roleSet_id` varchar(32) NOT NULL, ...

  3. webpack—入门

    点击进入webpack官网.,开始教程时,建议先学习ES6语法,也请先观看本篇Windows符号介绍文章,当所有webpack内容学习完后,会有一个专门的介绍 webpack四个核心概念(从官网入门— ...

  4. makefile中的一点知识

    makefile文件里以下这一部分展开是什么样的呢? .. . mytarget=foo  $(mytarget): $(mytarget).c        gcc -o $(mytarget) $ ...

  5. tt1

    DIm #include iostream.h#include iostream.h# #include iostream.h http://www.cnblogs.com/cmt/archive/2 ...

  6. tesnorflow conv deconv,padding

    1.padding test input = tf.placeholder(tf.float32, shape=(1,2, 2,1)) simpleconv=slim.conv2d(input,1,[ ...

  7. BZOJ 1055 区间DP

    1055: [HAOI2008]玩具取名 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1144  Solved: 668[Submit][Statu ...

  8. 安卓图片载入之使用universalimageloader载入圆形圆角图片

    前言 话说这universalimageloader载入图片对搞过2年安卓程序都是用烂了再熟悉只是了.就是安卓新手也是百度就会有一大堆东西出来,今天为什么这里还要讲使用universalimagelo ...

  9. ubuntu 截图工具 Shutter,设置快捷键 Ctrl+Alt+A

    系统设置 键盘 快捷键 自定义快捷键

  10. java 语法 —— 数组

    1. 编译器不允许指定数组的大小 int[] a1; 既然编译器不允许指定数组的大小,现在 a1 拥有的只是对数组的一个引用,且未给该数组对象本身分配任何空间.为了给数组创建对应的存储空间,必须写初始 ...