poj 2352
来源:互联网 发布:德力西选型软件 编辑:程序博客网 时间:2024/06/05 18:13
题目:http://poj.org/problem?id=2352
树状数组,模版题。。直接按给定的顺序统计比当前X小于等于的星星个数即可。
#include <cmath>#include <ctime>#include <iostream>#include <string>#include <vector>#include <cstdio>#include <cstdlib>#include <cstring>#include <queue>#include <map>#include <set>#include <algorithm>#include <cctype>#include <stack>#include <deque>using namespace std;typedef long long LL;#define EPS 10e-9#define INF 0x3f3f3f3f#define REP(i,n) for(int i=0; i<(n); i++)const int maxn = 40000;int c[maxn];int ans[maxn];int lowbit(int x) { return x&-x;}void add(int x){ while(x<maxn){ c[x]+=1; x+=lowbit(x); }}int sum(int x){ int ret=0; while(x>0){ ret+=c[x]; x-=lowbit(x); } return ret;}int main(){ int n,x,y; while(scanf("%d",&n)!=EOF){ memset(ans,0,sizeof(ans)); for(int i=0;i<n;i++){ scanf("%d %d",&x,&y); x++;y++; ans[ sum(x)]++; add(x); } for(int i=0;i<n;i++) printf("%d\n",ans[i]); } return 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 STARS
- JAVA的web截图功能实现
- Mac 环境变量配置
- 进程系统调用——fork函数的深入理解使用
- 互联网线下活动一周整理 11月23日—29日
- Java communication software design 3(updating....)
- poj 2352
- 向linux内核中添加新的系统调用
- 设置jsp中pageEncoding为UTF-8
- 记录头像
- android 自定义processDialog
- java UIManager.getDefaults()
- SVN,GIT usage
- 单片机片外程序存储器数据存储器操作命令
- IIS下解析Excel文档“未在本地计算机上注册“Microsoft.ACE.OLEDB.12.0”提供程序”问题