记录编号 |
394084 |
评测结果 |
AAAAAAAAAA |
题目名称 |
树 |
最终得分 |
100 |
用户昵称 |
卍 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
1.313 s |
提交时间 |
2017-04-12 22:19:07 |
内存使用 |
49.76 MiB |
显示代码纯文本
type treed=record
l,r,x:longint;
end;
var
r:real;
tree:array[0..4000000]of treed;
a:array[0..1000000]of longint;
x,y,i,j,k,n,m:longint;
procedure make(l,r,x:longint);
var
mid:longint;
begin
tree[x].l:=l; tree[x].r:=r;
if l=r then tree[x].x:=a[l];
if l<>r then
begin
mid:=(l+r)shr 1;
make(l,mid,x shl 1);
make(mid+1,r,(x shl 1)+1);
tree[x].x:=tree[x shl 1].x+tree[(x shl 1)+1].x;
end;
end;
function sum(x,y,z:longint):longint;
var
mid:longint;
begin
if x>y then exit(0);
if (x=tree[z].l)and(y=tree[z].r) then exit(tree[z].x);
mid:=(tree[z].l+tree[z].r)shr 1;
if mid<x then sum:=sum(x,y,(z shl 1)+1)
else if mid>=y then sum:=sum(x,y,z shl 1)
else sum:=sum(x,mid,z shl 1)+sum(mid+1,y,(z shl 1)+1);
end;
procedure delete(mm,z,x:longint);
var mid:longint;
begin
tree[z].x:=tree[z].x-x;
if tree[z].l=tree[z].r then exit;
if tree[z shl 1].r>=mm then delete(mm,z shl 1,x) else delete(mm,(z shl 1)+1,x);
end;
begin
assign(input,'treed.in'); assign(output,'treed.out');
reset(input); rewrite(output);
readln(n);
for i:=1 to n do read(a[i]);
make(1,n,1);
readln(m);
for i:=1 to m do
begin
read(x,y);
r:=sum(x,y,1)*3.14;
writeln(r:0:2);
delete((x+y)shr 1,1,a[(x+y)shr 1]);
a[(x+y)shr 1]:=0;
end;
close(input); close(output);
end.