- 河蟹王国
- 2009-10-04 09:49:33 @
估计是输出的问题
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 条评论
-
我是天才他哥 LV 10 @ 2009-10-04 12:39:38
如果你确定程序没写错
把writeln换成write试试 -
2009-10-04 12:07:27@
.
............................不知道哦
- 1