tyvj 1427 小白逛公园
来源:互联网 发布:淘宝旗下产品 编辑:程序博客网 时间:2024/04/28 11:34
对我这种弱菜来说挺难的,算是抄的代码吧
#include <set>#include <map>#include <ctime>#include <queue>#include <cmath>#include <stack>#include <limits>#include <vector>#include <bitset>#include <string>#include <cstdio>#include <cstring>#include <fstream>#include <string.h>#include <iostream>#include <algorithm>#define LL long long#define Vi vector<int>#define Si set<int>#define readf freopen("input.txt","r",stdin)#define writef freopen("output.txt","w",stdout)#define FF(i,a) for(int i(0); i < (a); i++)#define FD(i,a) for(int i(a); i >= (1); i--)#define FOR(i,a,b) for(int i(a);i <= (b); i++)#define FOD(i,a,b) for(int i(a);i >= (b); i--)#define PD(a) printf("%d\n",a)#define SET(a,b) memset(a,b,sizeof(a))#define SD(a) scanf("%d",&(a))#define LN printf("\n")#define PS printf(" ")#define pb push_back#define lson l , m , rt << 1#define rson m + 1 , r , rt << 1 | 1const double pi = acos(-1.0);const int maxn = 301;const int INF = ~0U>>1;const int dx[]={0,1,0,-1};const int dy[]={1,0,-1,0};using namespace std;int A[maxn];struct info{ int L,R,M,S; info(int x=0):L(x),R(x),M(x),S(x){}}none;info operator+(const info&l,const info&r){ info f; if(l.M==-INF) return r; if(r.M==-INF) return l; f.L=max(l.L,l.S+r.L); f.R=max(r.R,r.S+l.R); f.S=l.S+r.S; f.M=max(l.M,r.M); f.M=max(f.M,l.R+r.L); return f;}info T[maxn*3];inline void Set(int t,int x){ T[t]=info(x);}void build(int t,int l,int r){ if(l+1==r){ Set(t,A[l]); return; } build(t*2,l,(l+r)/2); build(t*2+1,(l+r)/2,r); T[t]=T[t*2]+T[t*2+1];}void change(int t,int l,int r,int p,int s){ if(l+1==r){ Set(t,s);return; } if(p<(l+r)/2) change(t*2,l,(l+r)/2,p,s); else change(t*2+1,(l+r)/2,r,p,s); T[t]=T[t*2]+T[t*2+1];}info ask(int t,int l,int r,int a,int b){ if(b<=l||a>=r) return none; if(l>=a&&r<=b) return T[t]; return ask(t*2,l,(l+r)/2,a,b)+ask(t*2+1,(l+r)/2,r,a,b);}int main(){ none.M=-INF; int n,m,a,b,c; scanf("%d %d",&n,&m); FF(i,n)scanf("%d",A+i); build(1,0,n); while(m--) { scanf("%d %d %d",&a,&b,&c); if(a==1){ if(b>c) swap(b,c); printf("%d\n",ask(1,0,n,b-1,c).M); } else change(1,0,n,b-1,c); }}
- tyvj 1427 小白逛公园
- TYVJ 1427 小白逛公园
- TYVJ 1427 小白逛公园 线段树
- tyvj 1427 小白逛公园 (线段树)
- TYVJ P1427 小白逛公园
- Tyvj P1427 小白逛公园
- tyvj 1427 小白逛公园(线段树中级,单点修改,动态最大连续和)
- 小白逛公园
- 小白逛公园
- 小白逛公园
- 小白逛公园 --线段树
- 1756: Vijos1083 小白逛公园
- bzoj1756 Vijos1083 小白逛公园
- vijos-P1083 小白逛公园
- 【vijos1083】小白逛公园
- NKOI 1316 小白逛公园
- 小白逛公园(vijos1083)
- bzoj1756: Vijos1083 小白逛公园
- Windows线程的创建和终止
- 数据库事务和并发
- [ js处理表单 ]:保存、提交
- Vector、ArrayList和List的异同
- [Linux] Centos6 memcached
- tyvj 1427 小白逛公园
- Java基础知识总结
- C#多线程编程(1):线程的启动 .
- 【拓扑排序】hdu2094 产生冠军
- winfrom程序打包
- 多线程编程(2):线程的同步 .
- 多线程编程(3):线程池ThreadPool .
- [ js处理表单 ]:动态赋值
- 多线程编程(4):多线程与UI操作 .