help me

估计是输出的问题

var

l,r,i,j,k,m,n,max,sum:longint;

a,b:array[1..270000]of longint;

procedure insert(i,l,r,j,k:longint);

var mid:longint;

begin

if l=r then begin a[i]:=k;b[i]:=k;exit;end;

mid:=(l+r)shr 1;

if ja then a[i]:=a else a[i]:=a;

end;

procedure add(i,l,r,j,k:longint);

var mid:longint;

begin

if (j=l)and(k=r) then begin inc(a[i],sum);inc(b[i],sum);exit;end;

mid:=(l+r)shr 1;

if kmid then add(i+i+1,mid+1,r,j,k)

else begin add(i+i,l,mid,j,mid);add(i+i+1,mid+1,r,mid+1,k);end;

a[i]:=b[i];if a>a then inc(a[i],a) else inc(a[i],a);

end;

procedure find(i,l,r,j,k,now:longint);

var mid:longint;

begin

if (l=j)and(r=k) then begin if now+a[i]>max then max:=now+a[i];exit;end;

mid:=(l+r)shr 1;

if kmid then find(i+i+1,mid+1,r,j,k,now+b[i])

else begin find(i+i,l,mid,j,mid,now+b[i]);find(i+i+1,mid+1,r,mid+1,k,now+b[i]);end;

end;

begin

readln(n);

for i:=1 to 270000 do a[i]:=-maxlongint;

for i:=1 to n do

begin

readln(j);

insert(1,1,n,i,j);

end;

readln(m);

for i:=1 to m do

begin

read(j);

if j=1 then

begin

readln(l,r,sum);

add(1,1,n,l,r);

end else

begin

readln(l,r);

max:=-maxlongint;

find(1,1,n,l,r,0);

writeln(max);

end;

end;

end.

2 条评论

  • 1

信息

ID
1659
难度
7
分类
数据结构 | 线段树 点击显示
标签
(无)
递交数
2095
已通过
323
通过率
15%
被复制
12
上传者