| 记录编号 | 441740 | 评测结果 | AAAAAAAAAA | 
    
        | 题目名称 | 1361.树 | 最终得分 | 100 | 
    
        | 用户昵称 |  +1s | 是否通过 | 通过 | 
    
        | 代码语言 | C++ | 运行时间 | 1.068 s | 
    
        | 提交时间 | 2017-08-25 14:46:29 | 内存使用 | 23.94 MiB | 
    
    
    
    		显示代码纯文本
		
		//#include<fstream>
#include<iomanip>
#include<cstdio>
#define P 3.14
using namespace std;
//ifstream fin("treed.in");
//ofstream fout("treed.out");
int h[200020];
struct{int l,r,su;}stree[2000020];
int n,m;
void bui(int l,int r,int idx)
{
	stree[idx].l=l;
	stree[idx].r=r;
	stree[idx].su=0;
	if(l==r)
	{
		stree[idx].su=h[l];
		return;
	}
	int m=(l+r)>>1;
	bui(l,m,idx*2);
	bui(m+1,r,idx*2+1);
	stree[idx].su=stree[idx*2].su+stree[idx*2+1].su;
}
int qry(int l,int r,int idx)
{
	if(stree[idx].l==0&&stree[idx].r==0)return 0;
	if(stree[idx].l==l&&stree[idx].r==r)return stree[idx].su;
	if(r<=stree[idx*2].r)return qry(l,r,idx*2);
	if(l>=stree[idx*2+1].l)return qry(l,r,idx*2+1);
	return qry(l,stree[idx*2].r,idx*2)+qry(stree[idx*2+1].l,r,idx*2+1);
}
void del(int pos,int idx)
{
	if(stree[idx].l<=pos&&pos<=stree[idx].r)
	{
		stree[idx].su-=h[pos];
		del(pos,idx*2);
		del(pos,idx*2+1);
	}
}
int main()
{
	freopen("treed.in","r",stdin);
	freopen("treed.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d ",&h[i]);
	scanf("%d",&m);
	bui(1,n,1);
	int l,r;
	float o;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&l,&r);
		o=qry(l,r,1);
		printf("%.2f\n",o*P);
		del((l+r)>>1,1);
		h[(l+r)>>1]=0;
	}
	return 0;
}