#include #include #define REP(i,n) for(int i=0,i##_len=(n);i ans2(ll N,ll Q,vector> A,vector X){ vector x(N+1,0),w(N+1,0),Sxw(N+2,0),Sw(N+2,0); REP(i,N){ x[i+1]=A[i].first; w[i+1]=A[i].second; } REP(i,N+1){ Sxw[i+1]=Sxw[i]+x[i]*w[i]; Sw[i+1]=Sw[i]+w[i]; } int k=0; vector res; REP(q,Q){ while(k<=N&&X[q]>=x[k]){ k++; } res.push_back(Sxw[N+1]-2*Sxw[k]+X[q]*(2*Sw[k]-Sw[N+1])); } return res; } int main(){ ll N,Q;cin>>N>>Q; assert(1<=N&&N<=100000); assert(1<=Q&&Q<=100000); vector> A(N); REP(i,N){ cin>>A[i].first>>A[i].second; assert(1<=A[i].first&&A[i].first<=1000000000); assert(1<=A[i].second&&A[i].second<=10000); if(i>0) assert(A[i].first>A[i-1].first); } vector X(Q); REP(i,Q){ cin>>X[i]; assert(1<=X[i]&&X[i]<=1000000000); if(i>0) assert(X[i]>X[i-1]); } vector ans=ans2(N,Q,A,X); REP(i,Q){ cout<