- 天才的记忆
- 2009-03-27 09:04:23 @
var
n,a,b,k,q,rmq:int64;
i,j:longint;
d:array[1..1000000,0..1000000] of int64;
function max(a,b:int64):int64;
begin
if a>b then exit(a) else exit(b);
end;
begin
readln(n);
for i:=1 to n do
read(d);
for j:=1 to trunc(ln(n)/ln(2)) do
for i:=1 to (n-1)shl(j+1) do
d:=max(d,d);
readln;readln(q);
for i:=1 to q do
begin
readln(a,b);
k:=trunc(ln(b-a+1)/ln(2));
rmq:=max(d[a,k],d);
writeln(rmq);
end;
end.
2 条评论
-
prince_hao LV 10 @ 2009-10-11 17:59:55
一个数组就开到800G
今天算是开了眼界! -
2009-03-27 11:56:31@
orz大牛,这道题好像不需要开那么大的数组
PS:(rmq好像也不是那样写的)
- 1