当初只会暴力,现在差不多觉得水了
显然离线处理,对输入的数排序然后会发现不管怎么修改都是结果总是单调不降的
对于每次处理,我们只要找到那段越界的即可
显然上线段树,话说jsoi这么喜欢线段树?
下面在bzoj上过不去,因为pascal编译器处理比较严格,可能某处爆了int64,我也懒得查了,本地是能过的
type node=record
mi,mx,att,mul,an:int64;
end; var tree:array[..*] of node;
ans,b,c:array[..] of longint;
a:array[..] of int64;
ch:array[..] of char;
m,f,t,i,n:longint; procedure swap(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end; procedure sort(l,r:longint);
var i,j:longint;
x,y:int64; begin
i:=l;
j:=r;
x:=a[(l+r) shr ];
repeat
while a[i]<x do inc(i);
while x<a[j] do dec(j);
if not(i>j) then
begin
y:=a[i]; a[i]:=a[j]; a[j]:=y;
swap(c[i],c[j]);
inc(i);
dec(j);
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end; procedure cal(i,x,y:longint;x1,x2,x3:int64);
begin
with tree[i] do
begin
mi:=mi*x1+x2*a[x]+x3;
mx:=mx*x1+x2*a[y]+x3;
mul:=mul*x1;
att:=att*x1;
an:=an*x1;
att:=att+x2;
an:=an+x3;
end;
end; procedure build(i,l,r:longint);
var m:longint;
begin
tree[i].mi:=a[l];
tree[i].mx:=a[r];
tree[i].mul:=;
if l<>r then
begin
m:=(l+r) shr ;
build(i*,l,m);
build(i*+,m+,r);
end;
end; procedure push(i,l,r:longint);
var m:longint;
begin
m:=(l+r) shr ;
with tree[i] do
begin
cal(i*,l,m,mul,att,an);
cal(i*+,m+,r,mul,att,an);
mul:=;
att:=;
an:=;
end;
end; procedure max(i,l,r:longint);
var m:longint;
begin
if l=r then cal(i,l,l,,,t)
else begin
m:=(l+r) shr ;
push(i,l,r);
if tree[i*].mx>t then
begin
cal(i*+,m+,r,,,t);
max(i*,l,m);
end
else max(i*+,m+,r);
tree[i].mx:=tree[i*+].mx;
tree[i].mi:=tree[i*].mi;
end;
end; procedure min(i,l,r:longint);
var m:longint;
begin
if l=r then cal(i,l,l,,,f)
else begin
m:=(l+r) shr ;
push(i,l,r);
if tree[i*+].mi<f then
begin
cal(i*,l,m,,,f);
min(i*+,m+,r);
end
else min(i*,l,m);
tree[i].mx:=tree[i*+].mx;
tree[i].mi:=tree[i*].mi;
end;
end; procedure ask(i,l,r:longint);
var m:longint;
begin
if l=r then
ans[c[l]]:=tree[i].mx
else begin
m:=(l+r) shr ;
push(i,l,r);
ask(i*,l,m);
ask(i*+,m+,r);
end;
end; begin
readln(m,f,t);
for i:= to m do
readln(ch[i],b[i]);
readln(n);
for i:= to n do
begin
readln(a[i]);
if a[i]>t then a[i]:=t;
if a[i]<f then a[i]:=f;
c[i]:=i;
end;
sort(,n);
build(,,n);
for i:= to m do
if ch[i]='+' then
begin
cal(,,n,,,b[i]);
if tree[].mx>t then max(,,n);
end
else if ch[i]='-' then
begin
cal(,,n,,,-b[i]);
if tree[].mi<f then min(,,n);
end
else if ch[i]='*' then
begin
cal(,,n,b[i],,);
if tree[].mx>t then max(,,n);
end
else begin
cal(,,n,,b[i],);
if tree[].mx>t then max(,,n);
end;
ask(,,n);
for i:= to n do
writeln(ans[i]);
end.