1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 #include<cmath> 6 #include<algorithm> 7 #include<ctime> 8 #include<deque> 9 using namespace std; 10 const long long N=2000005; 11 long long n,m,x1,y11,x2,y2,t; 12 struct tree{ 13 long long l,r,a,b,c; 14 }tree[4*N]; 15 void build(long long o,long long l,long long r){ 16 tree[o].a=tree[o].b=tree[o].c=0; 17 tree[o].l=l; 18 tree[o].r=r; 19 if(l==r){ 20 return; 21 } 22 long long mid=(l+r)/2; 23 build(o*2,l,mid); 24 build(o*2+1,mid+1,r); 25 } 26 void pushdown(long long o){ 27 tree[o*2].a+=tree[o].a; 28 tree[o*2].b+=tree[o].b; 29 tree[o*2].c+=tree[o].c; 30 tree[o*2+1].a+=tree[o].a; 31 tree[o*2+1].b+=tree[o].b; 32 tree[o*2+1].c+=tree[o].c; 33 tree[o].a=tree[o].b=tree[o].c=0; 34 } 35 long long query(long long o,long long k){ 36 long long l=tree[o].l,r=tree[o].r; 37 if(l==r){ 38 return k*k*tree[o].a+k*tree[o].b+tree[o].c; 39 } 40 long long mid=(l+r)/2; 41 pushdown(o); 42 if(k<=mid){ 43 return query(o*2,k); 44 } 45 else{ 46 return query(o*2+1,k); 47 } 48 } 49 void update(long long o,long long ql,long long qr,long long a,long long b,long long c){ 50 long long l=tree[o].l,r=tree[o].r; 51 if(ql<=l&&r<=qr){ 52 tree[o].a+=a; 53 tree[o].b+=b; 54 tree[o].c+=c; 55 return; 56 } 57 long long mid=(l+r)/2; 58 if(ql<=mid){ 59 update(o*2,ql,qr,a,b,c); 60 } 61 if(qr>mid){ 62 update(o*2+1,ql,qr,a,b,c); 63 } 64 } 65 int main(){ 66 scanf("%lld%lld",&n,&m); 67 build(1,1,200000); 68 for(long long i=1;i<=n;i++){ 69 scanf("%lld%lld%lld%lld",&x1,&y11,&x2,&y2); 70 update(1,max(x2,y2)+1,200000,0,0,(x2-x1)*(y2-y11)); 71 if(x2<y2){ 72 update(1,max(x2,y11)+1,y2,0,x2-x1,y11*(x1-x2)); 73 } 74 else{ 75 update(1,max(x1,y2)+1,x2,0,y2-y11,x1*(y11-y2)); 76 } 77 if(max(x1,y11)<min(x2,y2)){ 78 update(1,max(x1,y11),min(x2,y2),1,-(x1+y11),x1*y11); 79 } 80 } 81 for(long long i=1;i<=m;i++){ 82 scanf("%lld",&t); 83 printf("%lld ",query(1,t)); 84 } 85 return 0; 86 }