CF816B Karen and Coffee
思路:
有点类似于区间修改点查询的树状数组。
实现:
#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的更多相关文章
- B. Karen and Coffee
B. Karen and Coffee time limit per test 2.5 seconds memory limit per test 512 megabytes input standa ...
- CodeForces 816B Karen and Coffee(前缀和,大量查询)
CodeForces 816B Karen and Coffee(前缀和,大量查询) Description Karen, a coffee aficionado, wants to know the ...
- codeforces round #419 B. Karen and Coffee
To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...
- Karen and Coffee CodeForces - 816B (差分数组+预处理前缀和)
To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...
- 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 ...
- 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 ...
- 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 ...
- Karen and Coffee CF 816B(前缀和)
Description To stay woke and attentive(专注的) during classes, Karen needs some coffee! Karen, a coffee ...
- CF 816B Karen and Coffee【前缀和/差分】
To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...
随机推荐
- 看我如何基于Python&Facepp打造智能监控系统
由于种种原因,最近想亲自做一个基于python&facepp打造的智能监控系统. 0×00:萌芽 1:暑假在家很无聊 想出去玩,找不到人.玩个lol(已卸载),老是坑人.实在是无聊至极,不过, ...
- Xcode中git的用法介绍与"Please tell me who you are"问题的解决方式
我在之前多篇博客中解说了怎样使用命令行操作git,能够大大提高我们的工作效率.详细能够參考<Git学习札记><Git学习札记--进阶>等文章.事实上对于同一个工具,我们有不同的 ...
- redux 简明学习
核心概念 redux专注于状态管理,把所有的状态都存在一个对象中.核心概念包括:store.state.action.reducer [store] store是保存数据的地方,redux提供crea ...
- js坑爹笔试题目汇总(持续更新中)
把你的面试官问倒,你就是一个合格的面试者了,以下总结一些易错的js笔试题目,会持续更新中.欢迎关注 1,考察this var length = 10 function fn(){ alert(this ...
- 2013级C++第12周(春)项目——成员的訪问属性、多重继承
课程首页在:http://blog.csdn.net/sxhelijian/article/details/11890759,内有完整教学方案及资源链接 第一部分 程序阅读 1.阅读程序.分析类中成员 ...
- 使用逆向工程生成mybatis的Mapper文件
之前有写过一篇博客: 使用MyBatis Generator自动生成MyBatis的代码链接:http://www.cnblogs.com/klslb/p/6908535.html 这个太麻烦了,而且 ...
- 【bzoj3124】[Sdoi2013]直径
1.求树的直径: 先随便取一个点,一遍dfs找到离它最远的点l1,再以l1为起点做一遍dfs,找到离l1最远的点l2 那么l1到l2的距离即为直径 2. 求出有多少条边在这棵树的所有直径上: ...
- Hadoop安装配置(ubuntu-12.04.2-server-amd64)
环境如下: ubuntu-12.04.2-server-amd64 hadoop-1.0.4 VirtualBox 1.在VBox中安装Ubuntu Server,用户名和密码都是hadoop,安装完 ...
- GitHub上README.md教程(copy)
[说明:转载于http://blog.csdn.net/kaitiren/article/details/38513715] 最近对它的README.md文件颇为感兴趣.便写下这贴,帮助更多的还不会编 ...
- PHP面向对象技术(全面讲解)
作者:高洛峰 来源:<PHPer>杂志 1.面向对象的概念 面向对象编程(Object Oriented Programming, OOP, 面向对象程序设计)是一种计算机 ...