hdu 1754 I hate it
来源:互联网 发布:c socket linux编程 编辑:程序博客网 时间:2024/06/18 00:29
http://acm.hdu.edu.cn/showproblem.php?pid=1754
#include <cstdio>using namespace std;const int maxx=200000;int sum[maxx<<2];#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1int MAX(int a, int b){ return a>b?a:b;}void pushup(int rt){ sum[rt]=MAX(sum[rt<<1],sum[rt<<1|1]);}void build(int l,int r,int rt){ if(l==r) { scanf("%d",&sum[rt]); return; } int m=(l+r)>>1; build(lson); build(rson); pushup(rt);}void update(int p, int b,int l, int r, int rt){ if(l==r) { sum[rt]=b; return; } int m=(l+r)>>1; if(p<=m) update(p,b,lson); else update(p,b,rson); pushup(rt);}int query(int L,int R,int l, int r, int rt){ if(L<=l&&r<=R) return sum[rt]; int m =(l+r)>>1; int res=0; if(L<=m) res=MAX(res,query(L,R,lson)); if(R>m) res=MAX(res,query(L,R,rson)); return res;}int main(){ int m,n,a,c; while(~scanf("%d %d",&m,&n)) { build(1,m,1); while(n--) { char op[2]; scanf("%s%d%d",op,&a,&c); if(op[0]=='Q') printf("%d\n",query(a,c,1,m,1)); else update(a,c,1,m,1); } } return 0;}
0 0
- hdu 1754 I Hate It
- HDU 1754 I Hate It
- hdu 1754 I Hate It
- HDU 1754 I Hate It
- hdu 1754 I Hate It
- HDU 1754 I Hate It .
- HDU 1754 i hate it
- hdu 1754 I Hate It
- hdu 1754 I Hate It
- hdu 1754 I Hate It
- HDU 1754(I Hate It )
- hdu 1754 I Hate It
- hdu 1754 I Hate It
- HDU-1754-I Hate It
- hdu 1754 I Hate It
- hdu 1754 I Hate It
- hdu 1754 I hate it
- HDU 1754 I Hate It
- 图片上传之fileupload
- 解决ThinkPad S3-440无法睡眠问题
- 下载代码整理
- Flask Ajax Demo
- 三方通话(二)
- hdu 1754 I hate it
- sicily 1214 二进制回文数的证明
- python计算机视觉
- Cocos2d-x的学习之旅(二)HelloWorld
- 内存泄露、内存溢出以及解决方法
- C++设计模式---策略模式
- FutureTask 源码分析
- QT下实现对Linux Shell调用的几种方法
- kyeremal-poj1330-Nearest Common Ancestors-最近公共祖先