poj 2352 树状数组
来源:互联网 发布:php常用函数有哪几个 编辑:程序博客网 时间:2024/06/14 06:24
#include<iostream>#include<cstdio>#include<string.h>#include<cstring>#include<string>#include<algorithm>using namespace std;const int maxn = 15005;const int maxx = 32050;int ar[maxx], lev[maxn];int n;int lowbit(int x){ return x & (-x);}int sum(int x){ int ret = 0; while(x > 0){ ret += ar[x]; x -= lowbit(x); } return ret;}void add(int x){ while(x < maxx){ ar[x] += 1; x += lowbit(x); }}int main(){ int x, y; while(scanf("%d", &n)!=EOF){ memset(lev, 0, sizeof(lev)); memset(ar, 0, sizeof(ar)); for(int i = 0; i < n; ++i){ scanf("%d%d",&x, &y); ++x; lev[sum(x)]++; add(x); } for(int i = 0; i < n; ++i){ printf("%d\n", lev[i]); } } return 0;}
0 0
- POJ 2352 树状数组
- poj 2352 树状数组
- POJ 2352 树状数组
- poj 2352(树状数组)
- POJ 2352 树状数组
- POJ 2352 (树状数组)
- poj 2352 树状数组
- poj 2352树状数组
- 【树状数组】poj 2352
- POJ 2352(树状数组)
- poj 2352 树状数组
- poj 2352 树状数组
- poj 2352 树状数组
- poj 2352 树状数组
- POJ 2352 树状数组
- poj 2352 树状数组
- poj 2352 树状数组
- poj 2352 树状数组
- 黑马程序员-JAVASE入门(泛型)
- 字符串(堆分配存储)11种操作的实现
- 字符串的定长顺序存储表示与块链存储表示
- ios 预留
- reverse a linked list
- poj 2352 树状数组
- 把web项目改造为maven项目
- java Log4j使用介绍
- can I win(judge first player to move can win)
- 杭电 HDU ACM 1708 Fibonacci String
- 2015.4.7-4.8 widget中使用Listview (上)分析说明
- 打造自己的安卓Metro界面
- OpenCV之利用鼠标获取坐标
- 黑马程序员-JAVASE入门(内省、注解、类加载器)