#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100100;
int n;
int value[maxn];
int res[maxn]; int main()
{
int a, b;
while(scanf("%d", &n) != EOF && n) {
for(int i = 0; i <= n; i++) {
value[i] = 0;
res[i] = 0;
}
for(int i = 1; i <= n; i++) {
scanf("%d%d", &a, &b);
value[a] += 1;
value[b+1] += -1;
}
int result = 0;
for(int i = 1; i <= n; i++) {
result += value[i];
res[i] = result;
}
for(int i = 1; i < n; i++) {
printf("%d ", res[i]);
}
printf("%d\n", res[n]);
}
return 0;
}

hdu1556 Color the ball的更多相关文章

  1. HDU1556 Color the ball & 牛客 contest 135-I 区间 [差分标记]

    一.差分标记介绍 差分标记用来解决针对区间(修改-查询)的问题,复杂度比线段树要更低.推荐这个博客. 例如,给数组中处于某个区间的数进行加减操作,然后查询某个位置上数的变化值. 二.HDU1556 C ...

  2. HDU1556 Color the ball(差分数组)题解

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  3. hdu1556 Color the ball 简单线段树

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1556 简单的线段树的应用 直接贴代码了: 代码: #include<iostream> # ...

  4. hdu1556 Color the ball 线段树区间染色问题

    都是老套路了,如果n=5,要把区间[1,4]染色,可以递归去染区间[1,3]和区间[4,4],如果区间相等就自加,不相等继续递归寻找对应区间. 打印结果时,把所有到达叶节点包含i的区间值相加,就是最后 ...

  5. HDU1556:Color the ball(简单的线段树区域更新)

    http://acm.hdu.edu.cn/showproblem.php?pid=1556 Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定 ...

  6. HDU1556 Color the ball [线段树模板]

    题意:区间修改序列值,最后输出. //hdu1166 #include<iostream> #include<cstdio> #include<cstring> # ...

  7. Color the ball(hdu1556)(hash)或(线段树,区间更新)

    Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...

  8. HDU-1556:Color the ball(前缀和)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  9. HDU 1556 Color the ball(线段树区间更新)

    Color the ball 我真的该认真的复习一下以前没懂的知识了,今天看了一下线段树,以前只会用模板,现在看懂了之后,发现还有这么多巧妙的地方,好厉害啊 所以就应该尽量搞懂 弄明白每个知识点 [题 ...

随机推荐

  1. [置顶] java ant 配置及构建项目

      Ant是一种基于Java的构建工具.Ant文件是配置构建目标过程的XML文件,也称为Ant脚本.                     (因为对这个不是很了解,所以用词方面可能于个人的理解有偏差 ...

  2. linux find命令-print0和xargs中-0使用技巧(转载)

    本文介绍了linux find命令中-print0和xargs中-0用法技巧,一些find命令的使用经验,需要的朋友参考下. 本节内容:linux find命令中-print0和xargs中-0的用法 ...

  3. jquery 自动跳出列表

    先上效果图:当鼠标经过相亲会自动弹出取最新的10条数据

  4. redis知识

    http://www.cnblogs.com/moon521/p/5301895.html 菜鸟教程:http://www.runoob.com/redis/redis-tutorial.html

  5. CharacterController 角色控制器实现移动和跳跃

    之前我使用SimpleMove来控制角色的移动, 后来又想实现人物的跳跃, 看见圣典里面是使用Move来实现的. =.= 然后我都把他们改成move来实现了 代码实现: using UnityEngi ...

  6. iOS获取一个方法的执行时间

    #import <Foundation/Foundation.h> #import <mach/mach_time.h> typedef void (^block)(void) ...

  7. LDA-线性判别分析(一)

    本来是要调研 Latent Dirichlet Allocation 的那个 LDA 的, 没想到查到很多关于 Linear Discriminant Analysis 这个 LDA 的资料.初步看了 ...

  8. 练习使用jquery.并将验证强度的功能加到注册页面中

  9. ArcGIS10.3.1于2015年6月发布

    http://www.esrichina.com.cn/sectorapplication/ArcGIS%2010.3/index.html

  10. Mysql常用命令行大全(转)

    第一招.mysql服务的启动和停止 net stop mysql net start mysql 第二招.登陆mysql 语法如下: mysql -u用户名 -p用户密码 键入命令mysql -uro ...