hdu1556 Color the ball(树状数组)
来源:互联网 发布:汉王考勤软件下载 编辑:程序博客网 时间:2024/06/06 02:30
还是树状数组,只不过这题范围大一点。
#include <stdio.h>#include <algorithm>#include <stdlib.h>#include <string.h>#include <iostream>using namespace std;typedef long long LL;const int N = 100010;const int INF = 1e8;int tree[N];int level[N];int lowbit(int x){ return (x & -x);}void add(int x, int val){ while(x < N) { tree[x] += val; x += lowbit(x); }}int sum(int x){ int rankk = 0; while(x > 0) { rankk += tree[x]; x -= lowbit(x); } return rankk;}int main(){ // freopen("in.txt", "r", stdin); int x, y, n; while(~scanf("%d", &n) && n) { memset(tree, 0, sizeof(tree)); for(int i = 1; i <= n; i ++) { scanf("%d%d", &x, &y); add(x, 1); add(y + 1, -1); } for(int i = 1; i < n; i ++) { printf("%d ", sum(i)); } printf("%d\n", sum(n)); } return 0;}
0 0
- hdu1556 Color the ball(树状数组)
- 【HDU1556】Color the ball(树状数组)
- 【HDU1556-color the ball】(树状数组)
- HDU1556 color the ball (树状数组)
- hdu1556 Color the ball (树状数组)
- HDU1556 Color the ball (树状数组)
- [树状数组]HDU1556 Color the ball
- Hdu1556 Color the ball [分块][树状数组]
- [HDU1556] Color the ball - 树状数组
- HDU1556 Color the ball (树状数组)
- hdu1556 Color the ball 树状数组
- 树状数组:HDU1556 Color the ball 【区间更新,单点查询]
- HDU1556 color the ball【树状数组】解题报告
- HDU1556 Color the ball【树状数组】【区间更新】
- HDU1556 color the ball(树状数组)向下查询,向上统计
- hdu1556 Color the ball(树状数组 修改区间,查找值)
- HDU1556 Color the ball(树状数组+抖机灵)
- 【树状数组-区间更新】hdu1556 Color the ball
- 图的表示
- 一、hbase的核心数据结构
- Atitit.jpg png格式差别以及解决jpg图片不显示的问题
- maven 手动把本地jar安装到本地仓库,maven手动安装依赖jar包
- SGU 104 Little shop of flowers【DP】
- hdu1556 Color the ball(树状数组)
- hdu1754 I Hate It(单点更新)
- Ubuntu清理无用的软件包级更新源方法
- hdu1394 Minimum Inversion Number(单点更新)
- hdu-4605 Magic Ball Game[离散化+回溯+树状数组]
- HDU 5606 tree BestCoder Round #68 (div.2) [思维]【数学】
- Atitit.隔行换色 变色 css3 结构性伪类选择器
- 命令行SVN Client的命令
- PAT-B 1028. 人口普查