hdu1556 Color the ball
#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的更多相关文章
- HDU1556 Color the ball & 牛客 contest 135-I 区间 [差分标记]
一.差分标记介绍 差分标记用来解决针对区间(修改-查询)的问题,复杂度比线段树要更低.推荐这个博客. 例如,给数组中处于某个区间的数进行加减操作,然后查询某个位置上数的变化值. 二.HDU1556 C ...
- HDU1556 Color the ball(差分数组)题解
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu1556 Color the ball 简单线段树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1556 简单的线段树的应用 直接贴代码了: 代码: #include<iostream> # ...
- hdu1556 Color the ball 线段树区间染色问题
都是老套路了,如果n=5,要把区间[1,4]染色,可以递归去染区间[1,3]和区间[4,4],如果区间相等就自加,不相等继续递归寻找对应区间. 打印结果时,把所有到达叶节点包含i的区间值相加,就是最后 ...
- HDU1556:Color the ball(简单的线段树区域更新)
http://acm.hdu.edu.cn/showproblem.php?pid=1556 Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定 ...
- HDU1556 Color the ball [线段树模板]
题意:区间修改序列值,最后输出. //hdu1166 #include<iostream> #include<cstdio> #include<cstring> # ...
- Color the ball(hdu1556)(hash)或(线段树,区间更新)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDU-1556:Color the ball(前缀和)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU 1556 Color the ball(线段树区间更新)
Color the ball 我真的该认真的复习一下以前没懂的知识了,今天看了一下线段树,以前只会用模板,现在看懂了之后,发现还有这么多巧妙的地方,好厉害啊 所以就应该尽量搞懂 弄明白每个知识点 [题 ...
随机推荐
- Lua Table 操作
Lua中table类似与C#种的字典,其实就是一个key-value键值对数据结构.来学习下table基本操作 Table的创建 myTable = {} --表名后面使用{}赋值,表示一个空的表 m ...
- Duanxx的STM32学习: STM32的存储映射
- fatal error: malformed or corrupted AST file: 'Unable to load module "/Users/apple/Library/Developer
在同一时候安装使用Xcode5, Xcode6之后, 常常遇到这个问题. fatal error: malformed or corrupted AST file: 'Unable to load m ...
- 7. 稀疏表示之OMP,SOMP算法及openCV实现
一.前言 稀疏表示是自上世纪90年代开始,从人眼的视觉感受野获得启示,逐渐被人们所研究.现在已经发展为一种重要的信息表示方法.所谓稀疏表示是指,一个信号在过完备字典中,可以由少数个原子线性表达, 其数 ...
- [跟我学spring学习笔记][IoC]
IoC基础 什么是IoC Ioc—Inversion of Control,即“控制反转”,不是什么技术,而是一种设计思想. ioc做什么 IoC容器帮对象找相应的依赖对象并注入,而不是由对象主动去找 ...
- 如何排版 微信公众号「代码块」之 MarkEditor
前段时间写过一篇文章 如何排版微信公众号「代码块」,讲的是如何使用浏览器插件 Markdown Here 来排版代码块.虽然用 Markdown Here 排版出来的样式还不错,但存在一个问题,就是代 ...
- 使用repo的本地开发流程
repo下的本地开发流程 单分支开发: 1 本地新建工作目录并初始化repo库: repo init; 2 下载代码(只取服务器当前分支): repo sync -c; 3 创建本地 ...
- PHP学习笔记三十八【下载】
<?php //演示下载一个图片 $file_name="SunSet.jpg"; $file_name=iconv("utf-8","gb23 ...
- 第四课 Grid Control实验 安装JCH2库并且配置好监听,关键步骤和结果截图
--从OCM 虚拟机中,克隆了安装oracle之前的状态 配置网络: [root@localhost network-scripts]# ifup ifcfg-eth0 [root@localho ...
- nginx配置文件(反向代理+集群+动静分离)
1.nginx纯反向代理配置(nginx.conf): #user nobody;worker_processes 4;error_log logs/error.log info;pid logs/n ...