题意:在1到n的气球中,在不同的区域中涂颜色,问每个气球涂几次。

#include<cstdio>
int num[100010];
int main()
{
 int n, x, y;;
 while (scanf("%d", &n), n)
 {
  for (int i = 0; i < n; i++)
  {
   scanf("%d%d", &x, &y);
   num[x] += 1; num[y + 1] -= 1;
  }
  for (int i = 2; i <= n + 1; i++)
   num[i] += num[i - 1];
  printf("%d", num[1]); num[1] = 0;
  for (int i = 2; i <= n; i++)
  {
   printf(" %d", num[i]); num[i] = 0;
  }
  printf("\n");
 }

}

Color the ball HDU - 1556 (非线段树做法)的更多相关文章

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

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

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

    #include<stdio.h> #include<string.h> ]; int main() { int n,i; int a,b; while(scanf(" ...

  3. HDU 1556【线段树区间更新】

    这篇lazy讲的很棒: https://www.douban.com/note/273509745/ if(tree[rt].l == l && r == tree[rt].r) 这里 ...

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

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

  5. hdu 4031 attack 线段树区间更新

    Attack Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Subm ...

  6. hdu 4288 离线线段树+间隔求和

    Coder Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  7. hdu 3016 dp+线段树

    Man Down Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  8. HDU 4605 Magic Ball Game(可持续化线段树,树状数组,离散化)

    Magic Ball Game Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  9. Necklace HDU - 3874 (线段树/树状数组 + 离线处理)

    Necklace HDU - 3874  Mery has a beautiful necklace. The necklace is made up of N magic balls. Each b ...

随机推荐

  1. R语言实战 —— 常见问题解决方法

    1.不存在叫XXX这个名字的程序包 > library(reshape) Error in library(reshape) : 不存在叫‘reshape’这个名字的程辑包 解决方法:先安装,后 ...

  2. Rancher2.0构建kubernetes(K8S)集群

    一.环境准备 1.准备至少3台CentOS7版本的虚拟机 # IP地址 主机名称 192.168.1.160 rancher 192.168.1.161 master 192.168.1.162 no ...

  3. Spring源码分析之IoC容器初始化

    本文首发于cdream个人博客(点击获得更加阅读体验) 欢迎转载,转载请注明出处 作为一个java程序员,保守估计一年里也都有300天要和Spring有亲密接触~~像我这种怕是每天都要撸撸Spring ...

  4. 【 js 工具 】如何使用Git上传本地项目到github?(mac版)

    在此假设你已经在 github 上创建好了一个项目,像这样: 并且你已经完成了自己的项目代码, 同时你也已经安装了 git,然后 let's start. 首先,建一个文件夹比如文中演示的是 微信小程 ...

  5. canvas-star4.html

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. linux学习笔记-目录相关知识

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! linux的目录结构及作用是根据fhs标准定制的,以下列出一些常用的目录的作用,以及fhs官方网站的连接 FHS官方网站的连接: ...

  7. MySQL and Sql Server:Getting metadata using sql script (SQL-92 standard)

    MySQL: use sakila; -- show fields from table_name; -- show keys from table_name; SELECT `REFERENCED_ ...

  8. csharp: sum columns or rows in a dataTable

    DataTable dt = setData(); // Sum rows. //foreach (DataRow row in dt.Rows) //{ // int rowTotal = 0; / ...

  9. 在线客服兼容谷歌Chrome、苹果Safari、Opera浏览器的修改

    纵览全网提供的众多号称兼容多浏览器的自动收缩在线客服,其实只兼容了IE和FF两种,当遇到谷歌Chrome.苹果Safari.Opera浏览器时鼠标还没点到客服按钮就会自动缩回,实用效果完全打折 以下代 ...

  10. 使用脚手架快速搭建React项目

    create-react-app是Facebook官方推出的脚手架,基本可以零配置搭建基于webpack的React开发环境步骤: 打开控制台 进入你想要创建项目的目录文件下面 依次执行以下命令 np ...