1 #include 2 #include 3 #include 4 using namespace std; 5 typedef __int64 LL; 6 #define MAXN 30010 7 #define MAXM 100010 8 int a[MAXN],b[MAXN],vis[MAXN]; 9 LL ans[MAXM],tree[MAXN<<2];10 struct node11 {12 int left,right,pos;13 friend bool operator<(node a,node b)14 {15 return a.right >1;30 if(x<=mid)31 Update(x,val,L,mid,rt<<1);32 else33 Update(x,val,mid+1,R,rt<<1|1);34 PushUp(rt);35 }36 }37 LL Query(int x,int y,int L,int R,int rt)38 {39 if(x<=L&&R<=y)40 return tree[rt];41 int mid=(L+R)>>1;42 LL ans=0;43 if(x<=mid)44 ans+=Query(x,y,L,mid,rt<<1);45 if(y>mid)46 ans+=Query(x,y,mid+1,R,rt<<1|1);47 return ans;48 }49 int main()50 {51 int t,n,m,i,j,k,q;52 scanf("%d",&t);53 while(t--)54 {55 scanf("%d",&n);56 for(i=1;i<=n;i++)57 {58 scanf("%d",&a[i]);59 b[i]=a[i];60 }61 sort(b+1,b+1+n);62 m=unique(b+1,b+1+n)-b;63 scanf("%d",&q);64 for(i=0;i