N名同学拍成一排,编号为1,2,3,4 …… N。现在有一位老师需要检查所有同学的出勤情况,他会进行点名,每次给出两个数a,b,并且保证a小于等于b,这个区间内的所有同学都会被点名一次,老师会进行N次点名,请问点名结束后,每位同学被点名的总次数是多少

Input

每个测试实例第一行为一个整数N,(N <= 100000).

接下来的N行,每行包括2个整数a b(1 <= a <= b <= N)。

当N = 0,输入结束。

Output

每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共被涂色的次数。

Input Sample

3
1 1
2 2
3 3
3
1 1
1 2
1 3
0

Output Sample

1 1 1
3 2 1

分析

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10,INF=0x3f3f3f3f;
int n,m,a,b,d[N]; int main(){
while(cin>>n && n){
memset(d,0,sizeof(d));
m=n; while (m--){
cin>>a>>b;
d[a] ++;
d[b+1] --;
}
for(int i=1; i<=n; i++) d[i]+=d[i-1];
for(int i=1; i<=n; i++) cout<<d[i]<<" \n"[i==n];
}
}

Color the ball HDU - 1556 _差分的更多相关文章

  1. A - Color the ball HDU - 1556 (差分数组+前缀和)

    思路等引自博客 https://blog.csdn.net/johnwayne0317/article/details/84928568 对数组a[7]: a[0]=1; = d[0] a[1]=1; ...

  2. Color the ball HDU - 1556 (非线段树做法)

    题意:在1到n的气球中,在不同的区域中涂颜色,问每个气球涂几次. #include<cstdio>int num[100010];int main(){ int n, x, y;; whi ...

  3. Color the ball HDU - 1556 (线段树)

    思路:线段树,区间更新 #include<iostream> #include<vector> #include<string> #include<cmath ...

  4. 树状数组模板--Color the ball

    Color the ball HDU - 1556 N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电 ...

  5. hdu 1556:Color the ball(第二类树状数组 —— 区间更新,点求和)

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

  6. hdu 1556:Color the ball(线段树,区间更新,经典题)

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

  7. HDU.1556 Color the ball (线段树 区间更新 单点查询)

    HDU.1556 Color the ball (线段树 区间更新 单点查询) 题意分析 注意一下pushdown 和 pushup 模板类的题还真不能自己套啊,手写一遍才行 代码总览 #includ ...

  8. HDU 1556 Color the ball (数状数组)

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

  9. 线段树(求单结点) hdu 1556 Color the ball

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

  10. hdu 1556 Color the ball(区间更新,单点求值)

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

随机推荐

  1. MySQL/MariaDB如何创建用户并限制指定才能IP访问?

    MySQL/MariaDB如何创建用户并限制指定才能IP访问? 登入数据 $ mysql --version mysql Ver 15.1 Distrib 10.9.3-MariaDB, for de ...

  2. python实现两张图片拼接

    纵向拼接 from PIL import Image def image_splicing(pic01, pic02): """ 图片拼接 :param pic01: 图 ...

  3. python使用pysimplegui简单制作一个exe程序

    一.安装打包程序 控制台输入: pip install pysimplegui-exemaker -- 安装exe制作库 pip install PySimpleGUI -- 安装图形化界面编辑库 二 ...

  4. Qt 3D示例——cube

    Qt 3D官方示例 cube的3D演示,一个纯C++的项目.虽然QML示例比较炫,但是要深入理解还是得从C++例子入手. 从MainWidget.show入口.一步步可以跟踪到initializeGL ...

  5. CF14D题解

    CF14D Two Paths题解 题目链接 传送门 题意简述 给定一棵树,找出两条不经过相同点的最长路径,使得他们的长度乘积最大. 题目分析 首先,如果在一棵树上,两条路径没有共同的点,那么这两条路 ...

  6. Delphi获取程序版本号

    参考: http://www.delphitop.com/html/hanshu/4627.html procedure GetVersionInfo(const FileName:string; v ...

  7. 服务器consul与本地服务健康检查不通问题解决

    (125条消息) 服务器consul与本地服务健康检查不通问题解决_向往鸟的博客-CSDN博客_consul健康检查失败 .MathJax, .MathJax_Message, .MathJax_Pr ...

  8. 南大ics-pa/PA0过程及感想

    实验教程地址:https://nju-projectn.github.io/ics-pa-gitbook/ics2022/index.html 一.Ubuntu安装 在清华大学镜像站下载了Ubuntu ...

  9. 微信小程序中如何把数组从一个页面传到另一个页面,并且获取数据

    // 传送端 举例 wx.navigateTo({ url: 'recite/recite?openid=' + k.data.openid + '&isexist=' + k.data.is ...

  10. kuangbin学习

    是有针对性的对于算法的训练 我试试QAQ